以下は私のマニフェストファイルです。BOOT_COMPLETEDのBroadcastReceiverが遅すぎる
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mccheekati.test_trail">
<uses-permission
android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<receiver
android:name="com.example.mccheekati.test_trail.yourActivityRunOnStartup"
android:enabled="true"
android:exported="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON"
/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
次のように放送受信装置ではありません:
public class yourActivityRunOnStartup extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Intent i = new Intent(context, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
なしエラー。電話機の再起動時にアプリケーションが起動しています。しかし、再起動後にアプリケーションを起動するのに1分ほどかかることがあります。再起動後すぐにアプリケーションを起動する方法はありますか?
ありがとうございます。私はホーム画面モードを試して、それは働いた。しかし、電話機のデフォルトのホーム画面とカスタマイズしたホーム画面の間をナビゲートする方法はありますか? –
@mCheekati:「自分のアプリから携帯電話のデフォルトのホーム画面を起動できますか?」という場合は、答えは「はい」です。ホーム画面( 'ACTION_MAIN'、' CATEGORY_HOME')に 'PackageManager'、' queryIntentActivities() '、' Intent'を使うことで、その活動が何であるか把握する必要があります。あなたの活動は、結果リストに1 +その他のものとともに表示されます。適切なアクティビティを見つけたら、 'ACTION_MAIN' /' CATEGORY_HOME'' Intent'を起動する特定のアクティビティの 'ComponentName'で更新してください。 – CommonsWare
私は自分の携帯電話で利用可能なランチャーのリストを取り出しました。しかし、ホーム画面になるようにコンポーネントを設定することはできません。他のランチャーは少なくともオープンしています(いいえ、ホーム画面ではありません)。しかし、システムのデフォルトランチャーをクリックすると、残念なことにアプリがシャットダウンします。 –