カスタムアプリクラスがあります
public class MyApp extends Application {
public static Context application_context;
@Override
public void onCreate() {
super.onCreate();
application_context=getApplicationContext();
}
public static void startShareIntent() {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, "some text");
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");
application_context.startActivity(Intent.createChooser(shareIntent,
"Share with"));
}
}
このメソッドを呼び出すと、このエラーメッセージが表示されます
「Activity コンテキストの外部から startActivity() を呼び出すには、FLAG_ACTIVITY_NEW_TASK フラグが必要です。これでよろしいですか?」
はい、それは本当に欲しいのですが、なぜ私はそれができないのですか?