あなたが望むように直接行う方法はありません。ランチャーアクティビティを設定するには、マニフェストを編集する必要があります。実際には実行できません。それは以前に保存したアクティビティの名前を読んでのonCreate()メソッドだと、あなたが本当にアプリをクリックして起動する必要があり
<activity
android:name="com.sample.test.LauncherActivity"
android:label="@string/title_activity_main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
内側:
しかし、あなたが何ができるかは、このインテントフィルタを使用してマニフェストの一部LauncherActivity
を宣言することですアイコンをSharedPreferences
から選択して起動します。このように:
public class LauncherActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String activityToLaunch = getSharedPreferences("LauncherActivity", MODE_PRIVATE).getString("LauncherActivity", "Some default Activity");
Intent intent;
switch (activityToLaunch) {
case "SomeActivity1":
intent = new Intent(this, SomeActivity1.class);
break;
case "SomeActivity2":
intent = new Intent(this, SomeActivity2.class);
break;
case "SomeActivity3":
intent = new Intent(this, SomeActivity3.class);
break;
default:
intent = new Intent(this, SomeDefaultActivity.class);
break;
}
startActivity(intent);
finish();
}
}
あなたはここに参照することができますhttp://stackoverflow.com/questions/7414272/how-to-launch-an-android-app-without-android-intent-category-launcher – Raju