Is it possible to call a method from an Intent
? I need to call an notification method that I build and it has to be in this activity.
Intent locationNotific = new Intent("SendProximityIntent");
locationNotific.putExtra("RowID", id);
sendBroadcast(locationNotific);
PendingIntent lPendingIntent = PendingIntent.getActivity(this, 0,
locationNotific, 0);
lm.addProximityAlert((double) locationAlertGeoP.getLatitudeE6(),
(double) locationAlertGeoP.getLongitudeE6(),
(float) 999999999,(long) 100000, lPendingIntent);
No, but you can put an extra field the intent with a specific value. When the activity starts, parse the extra field and, if the value is found, call the desired method. Something like:
localNotific.putExtra("KEY_METHOD_TO_CALL", 1);
And in your activity:
onCreate... {
Intent intent = getIntent();
int value = -1;
if (null != intent) {
value = intent.getIntExtra("KEY_METHOD_TO_CALL", -1);
}
if (-1 != value) {
//Call your method here
}
}
Hope this help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.