GVKun编程网logo

android – 删除多个活动以从“选项”菜单返回“仪表板”(删除一些活动)

16

关于android–删除多个活动以从“选项”菜单返回“仪表板”和删除一些活动的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于AndroidStudio3.1在“工具”菜单下未显示“andr

关于android – 删除多个活动以从“选项”菜单返回“仪表板”删除一些活动的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Android Studio 3.1在“工具”菜单下未显示“android”选项、android – 一个活动到另一个活动之间的延迟、android – 一个活动的多个通知、android – 为多个活动存储位图?等相关知识的信息别忘了在本站进行查找喔。

本文目录一览:

android – 删除多个活动以从“选项”菜单返回“仪表板”(删除一些活动)

android – 删除多个活动以从“选项”菜单返回“仪表板”(删除一些活动)

我的Android应用程序中有一个Optionsmenu,其中有一个按钮可以返回到应用程序Dashboad并删除所有正在进行的活动,同时删除历史记录.这怎么可能?

谢谢

得到了答案:

这就是特技:

myIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

public boolean onoptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
    case R.id.dashboard:
        Intent myIntent = new Intent(this, DashBoard.class);
        myIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(myIntent);
        return true;
    default:
        return super.onoptionsItemSelected(item);
    }
}

解决方法:

这就是特技:

myIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

Android Studio 3.1在“工具”菜单下未显示“android”选项

Android Studio 3.1在“工具”菜单下未显示“android”选项

我正在使用android studio 3.1进行一些开发.
但它没有在工具菜单下显示android选项.而Android studio 3.0没有这个问题.

这是android studio 3.1工具菜单的截图:

enter image description here

看到缺少android选项.
我认为这是一些配置相关的问题,因为它在android studio 3.0中不存在.基本上我需要启用ADB集成选项.有没有办法在工具菜单中显示该选项?

解决方法:

如果您正在寻找一种方法来修复与物理连接的USB设备的错误连接而无需重新启动Android Studio,这可能会有所帮助:

偏好>建立,执行和部署>调试器

然后选中或取消选中使用libusb后端框

enter image description here

android – 一个活动到另一个活动之间的延迟

android – 一个活动到另一个活动之间的延迟

我在Android中开发了一个应用程序.其中包含如此多的数据(String)和图像.字符串数据来自数据库,图像来自/ res文件夹.

在我的应用程序第一活动中显示书籍的类别.然后我选择其中任何一个,然后跳转到下一个活动,显示所有书籍图像和所选类别的简要描述,这些所有数据都来自数据库,带有查询操作,并使用ArrayAdapter填充自定义列表视图.这些工作并显示我想要的所有东西.

但问题是,当我从一个活动中点击类别时,显示第二个活动(选定类别的详细信息)需要1分钟以上的时间.所以,这里的用户被卡住了.这对我的申请来说很糟糕.

那么有没有办法解决这些或任何想法显示一个活动到第二个活动之间的活动加载过程?

提前致谢.

请帮我解决这些问题.

解决方法:

使用AsyncTask作为

public class My_Game_Task extends AsyncTask<String, Void, Void> {


        @Override
        protected void onPreExecute() {
            //put a preloder
            super.onPreExecute();
        }

        @Override
        protected Void doInBackground(String... arg0) {
            // Todo Auto-generated method stub

            find data from database

            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            dismiss preloader
                            set adapter here
            super.onPostExecute(result);

        }

    }

打电话
          oncreate as new My_Game_Task().execute();
这将立即显示下一个活动并显示预加载器

android – 一个活动的多个通知

android – 一个活动的多个通知

实际上我的应用程序有一个活动.为了创建通知,我必须传递挂起的活动意图.

notificationmanager mgr=(notificationmanager)getSystemService(Context.NOTIFICATION_SERVICE);
        Notification note=new Notification(mob.app.R.drawable.message,"Message!",System.currentTimeMillis());
        // This pending intent will open after notification click
        PendingIntent i=PendingIntent.getActivity(this, 2,new Intent(this,SaleNotification.class),0);


        note.setLatestEventInfo(activity,messageheading,message, i);

        //After uncomment this line you will see number of notification arrived
        note.number=notifyNumber;
        mgr.notify(0, note);

这里SaleNotification.class不是一个活动.它是简单的类.
在这种情况下是否可以创建多个通知?以及如何?
提前致谢!

解决方法:

要拥有单独的通知,您需要为每个通知使用不同的ID.

这是一个简单的示例:

private int SIMPLE_NOTFICATION_ID_A = 0;
private int SIMPLE_NOTFICATION_ID_B = 1;

然后

// display A
displayNotification("Extra for A", "This is A", "Some text for activity A", MyActivityA.class, SIMPLE_NOTFICATION_ID_A);
// display B
displayNotification("Extra for B", "This is B", "Some text for activity B", MyActivityB.class, SIMPLE_NOTFICATION_ID_B);

和displayNotification:

private void displayNotification(String extra, String contentTitle, String contentText, Class<?> cls, int id) {     

  Notification notifyDetails = new Notification(R.drawable.icon, "New Alert!", System.currentTimeMillis());
  Intent intent = new Intent(this, cls);
  intent.putExtra("extra", extra);
  PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), id, intent, PendingIntent.FLAG_ONE_SHOT);
  notifyDetails.setLatestEventInfo(getApplicationContext(), contentTitle, contentText, contentIntent);
  mnotificationmanager.notify(id, notifyDetails);
}

android – 为多个活动存储位图?

android – 为多个活动存储位图?

我正在寻找一种方法来存储一些可由多个活动访问的位图,而无需从网上重新加载.

我不想简单地将它们从Activity转移到Activity,而是将它们放入Intent中,而是让我可以访问它们而不必传递它们.

我查看了缓存以帮助解决这个问题,但如果这是解决方案,我有点不清楚如何在多个活动中使缓存可访问.

任何建议或替代解决方案将不胜感激.

解决方法

您可以使用 LruCache,诸如 Volley之类的库,也可以自己实现相同的功能.我认为凌空图书馆对你来说是完美的.

要从应用程序的任何位置访问它,您应该将其存储在特殊的应用程序对象或静态变量中.请注意,此处仅存储对缓存的引用.在上面列出的两种情况下,缓存的大小都是可配置的.

关于android – 删除多个活动以从“选项”菜单返回“仪表板”删除一些活动的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于Android Studio 3.1在“工具”菜单下未显示“android”选项、android – 一个活动到另一个活动之间的延迟、android – 一个活动的多个通知、android – 为多个活动存储位图?等相关内容,可以在本站寻找。

本文标签: