开发者

Android: receiving intent sent by system ACTION_PACKAGE_RESTARTED

开发者 https://www.devze.com 2023-03-05 21:10 出处:网络
I am new to android. I get completely stuck in using ACTION_PACKAGE_RESTARTED in my application I have removed pacakge from my emulator, also added using adb install but get nothing. Start an app. cl

I am new to android. I get completely stuck in using ACTION_PACKAGE_RESTARTED in my application

I have removed pacakge from my emulator, also added using adb install but get nothing. Start an app. close that one and again start that app. nothing seems work for me. There is no log in logcat.

Is there anything that i'm missing? Please help

public class RestartReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
    String action= intent.getAction();
    Log.i("D", "Inside receiver");
}

And here is the manifest file

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <receiver android:name=".ReceiverTest">
 开发者_开发知识库       <intent-filter>
            <action android:name="android.intent.action.PACKAGE_REMOVED" />
            <action android:name="android.intent.action.PACKAGE_ADDED" />
            <action android:name="android.intent.action.ACTION_PACKAGE_RESTARTED" />
        </intent-filter>
    </receiver>

</application>


the value specified in the intent filter is incorrect..actual value is

<action android:name="android.intent.action.PACKAGE_RESTARTED" />

and this broadcast can be received for other packages only. Restarted application/package doesn't receive this broadcast.


You should add a data specification to the intent-filter:

<data android:scheme="package" />
0

精彩评论

暂无评论...
验证码 换一张
取 消