如何打开日历应用程序并同时在后台重启当前应用程序?
How to open Calendar app and restart current app in background simultaneously?
我当前的应用程序有一种情况,在点击对话框片段时,我必须在后台重新启动当前应用程序(或带回家 activity)并同时打开日历应用程序。我尝试同时发射 2 个意图,但没有成功。我也尝试使用 AsyncTask's executeOnExecutor
但并不总是保证顺序。有人可以解释一下如何处理这种情况吗?
您编写了以下代码以首先启动 activity,然后启动日历意图:
public void openCalendar(Context mCtx){
Intent activityIntent = new Intent(mCtx, HomeActivity.class);
startActivity(activityIntent );
Intent i = new Intent();
//Froyo or greater (mind you I just tested this on CM7 and the less than froyo one worked so it depends on the phone...)
cn = new ComponentName("com.google.android.calendar", "com.android.calendar.LaunchActivity");
//less than Froyo
cn = new ComponentName("com.android.calendar", "com.android.calendar.LaunchActivity");
i.setComponent(cn);
startActivity(i);
}
我当前的应用程序有一种情况,在点击对话框片段时,我必须在后台重新启动当前应用程序(或带回家 activity)并同时打开日历应用程序。我尝试同时发射 2 个意图,但没有成功。我也尝试使用 AsyncTask's executeOnExecutor
但并不总是保证顺序。有人可以解释一下如何处理这种情况吗?
您编写了以下代码以首先启动 activity,然后启动日历意图:
public void openCalendar(Context mCtx){
Intent activityIntent = new Intent(mCtx, HomeActivity.class);
startActivity(activityIntent );
Intent i = new Intent();
//Froyo or greater (mind you I just tested this on CM7 and the less than froyo one worked so it depends on the phone...)
cn = new ComponentName("com.google.android.calendar", "com.android.calendar.LaunchActivity");
//less than Froyo
cn = new ComponentName("com.android.calendar", "com.android.calendar.LaunchActivity");
i.setComponent(cn);
startActivity(i);
}