1

電話の再起動時にAndroidアプリケーションを自動的に再起動する方法。私はアンドロイド用のアプリを作りました、そして今私は電話が再起動されたときにそれが自動的に再起動することを望みます、誰かがこれについて私を助けてくれますか?

4

3 に答える 3

0
<receiver android:name=".BootReceiver" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
于 2012-08-22T11:35:50.613 に答える
0

BroadcastReceiverを使用して、BOOT_COMPLETEDブロードキャストをリッスンし、必要な処理を実行できます。

于 2012-08-22T11:32:51.050 に答える
0

http://www.anddev.org/launch_activity_on_system-emulator_startup-t428.htmlから

マニフェストで

  <receiver class=".MyStartupIntentReceiver">

            <intent-filter>

                 <action android:value="android.intent.action.BOOT_COMPLETED" />

                 <category android:value="android.intent.category.HOME" />

            </intent-filter>

        </receiver> 

MyStartupIntentReceiver クラス:

public class MyStartupIntentReceiver extends IntentReceiver {



        @Override

        public void onReceiveIntent(Context context, Intent intent) {

                /* Create intent which will finally start the Main-Activity. */

                Intent myStarterIntent = new Intent(context, LaunchOnStartup.class);

                /* Set the Launch-Flag to the Intent. */

                myStarterIntent.setLaunchFlags(Intent.NEW_TASK_LAUNCH);

                /* Send the Intent to the OS. */

                context.startActivity(myStarterIntent);

        }

}
于 2012-08-22T11:57:27.463 に答える