0

アプリケーションで、起動時に動作するレシーバーを実装しようとしています。そのために、 MyReceiver クラスを作成し、それをマニフェストに追加しました。許可も追加されています。しかし、それは機能せず、アプリ情報にも表示されません。

ここに私のマニフェストファイルがあります

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.inapp.sampleboot" >

    <uses-permission android:name="ANDROID.PERMISSION.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <receiver android:name=".MyReceiver"
            >
            <intent-filter>
                <action android:name="ANDROID.INTENT.ACTION.BOOT_COMPLETED"/>
                <action android:name="android.intent.action.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE" />
            </intent-filter>
        </receiver>
    </application>

</manifest>

私のレシーバークラス

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class MyReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {

    }
}
4

3 に答える 3

0

There are two actions in your receiver intent filter. That's the problem. Instead have two intent filter for the receiver.

Something like this perhaps:

<intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
<intent-filter>
                <action android:name="android.intent.action.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE" />
</intent-filter>

Do you really need the second action ?

Go through this if you face any other issue on this topic: https://stackoverflow.com/a/26026471/4747587

于 2015-10-21T07:28:18.263 に答える
0

インストール後にアプリケーションを少なくとも 1 回起動してから、デバイスを再起動してください。それがうまくいくことを願っています

于 2015-10-21T07:30:09.983 に答える
0

これで解決すると思います

<uses-permission android:name="ANDROID.PERMISSION.READ_EXTERNAL_STORAGE" />

Android では、ほとんどの場所で大文字と小文字が区別されます。これを次のように変更してください:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
于 2015-10-21T07:25:18.073 に答える