0

i like to know is there way to execute code in system app process in android. i found through pending intent we can assign our job to execute in foreign application like alarm manager or notification but still i found job gets execute in same application process .for clear understanding

Here i'm creating alarm manager on buttonclick event.

button.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View arg0) {
        Log.d("processstatus", "pid="+android.os.Process.myPid());
        //creating an alarm manager
        alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
        Intent intent = new Intent(context, customreciever.class);
        pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0); 
        alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,SystemClock.elapsedRealtime() +10*1000, pendingIntent );
    }
});

Through below code, i receive the broadcast event which gets triggered every interval of 10 sec through alarmmanager.

public class customreciever extends BroadcastReceiver {

    @Override
    public void onReceive(final Context context, Intent intent) {
     // Same app process id expecting alaramanager process id
            Log.d("processstatus", "pid="+android.os.Process.myPid());
    }
}

inside onReceive method i expect different process id other than application process.if this is not possible through pending intent,suggest me any other approach to achieve this.

Shaishav
  • 5,282
  • 2
  • 22
  • 41
user1955126
  • 79
  • 1
  • 2
  • 5

1 Answers1

0

You cannot run code in a system process. That would be a huge security hole.

Using a PendingIntent lets you delegate the triggering of code to another user/process/application, but the code still runs in your application with your user ID and your permissions.

David Wasser
  • 93,459
  • 16
  • 209
  • 274