2

i am new to android and i want to ask a question about android background services.

i have created a background service and which is activated after every one minute and pop up some message.

i want this service to activate to user whenever user installed another application to phone. is there any method to check this.

is there any method that check whenever any app is run for the first time and request user for permission?? OR what permission it requires from user??

Waiting for answer. Thanks in advance for good replies.

Tahir Mehmood
  • 89
  • 1
  • 15
  • A very similar question has been answered here: http://stackoverflow.com/questions/11394141/android-detect-when-app-is-installed – HonkyTonk Aug 19 '13 at 05:45

2 Answers2

0

Set up a BroadcastReceiver for the android.intent.action.PACKAGE_ADDED intent.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
0

Using Broadcast receiver you can do so as shown below:

public class MyBroadcastReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context arg0, Intent arg1) {
        // TODO Auto-generated method stub
        //Toast.makeText(arg0, "A New Package has been Installed!!!").show();

    }

}

You should register this broadcast receiver in your manifest as shown below:

 <receiver android:name=".MyBroadcastReceiver">
 <intent-filter>
  <action android:name="android.intent.action.PACKAGE_ADDED" /> 
  </intent-filter>
  </receiver>

From the above code a toast will be displayed whenever a new package is displayed. Hope this helps as it had worked for me.

Zax
  • 2,870
  • 7
  • 52
  • 76
  • is there any method that check whenever any app is run for the first time and request user for permission?? OR what permission it requires from user?? – Tahir Mehmood Aug 19 '13 at 05:58