我只是想知道我已经创建了一个应用程序并将其安装在我的设备上。是否可以仅使用广播接收器来启动该应用程序,如果可以,我该怎么做?
最佳答案
在您的应用程序未运行时使用以下代码打开 Activity。
Intent myIntent = new Intent(context.getApplicationContext(), YourClassActivity.class);
Bundle bundle = new Bundle();
myIntent.putExtras(bundle);
myIntent.addFlags(
Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.getApplicationContext().startActivity(myIntent);
你可以在 bundle 中传递任何数据,比如
bundle.putString("title", "from receiver");
关于android - 我可以使用广播接收器启动另一个应用程序吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15111140/