broadcastreceiver

Notification deleteIntent does not work

早过忘川 提交于 2020-01-09 10:04:11
问题 I've read several questions concerning similair issues, but they do not provide me with the solution. In my Android app I fire off a notification (in the Application class to be specific, which is actually started from a C2DM push event). I then want to receive an Intent when the "clear all" button is pressed on the notifications: notification.deleteIntent = PendingIntent.getService(this, 0, new Intent(this, NotificationDeleteReceiver.class), 0); In my NotificationDeleteReceiver.class I got

Get Context in a Service

安稳与你 提交于 2020-01-08 14:01:26
问题 Is there any reliable way to get a Context from a Service ? I want to register a broadcast receiver for ACTION_PHONE_STATE_CHANGED but I don't need my app to always get this information, so I don't put it in the Manifest . However, I can't have the broadcast receiver be killed by the GC when I need this information so I'm registering the broadcast receiver in a Service . Hence, I need a Context to to call registerReceiver() . When I no longer need the ACTION_PHONE_STATE_CHANGED I unregister

Android PendingIntent extras, not received by BroadcastReceiver

非 Y 不嫁゛ 提交于 2020-01-08 13:22:16
问题 When I pass extras to a PendingIntent, the message is never received by the sendBroadcastReceiver, because the onReceive() method of this BroadcastReceiver is never called. Why is this happening? public class MainActivity extends Activity { private static String SENT = "SMS_SENT"; private static String DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private BroadcastReceiver sendBroadcastReceiver, deliveryBroadcastReceiver;

How to get alert dialog only after disconnect call?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-07 08:02:17
问题 In my app i am doing one thing that,when the call is disconnected by caller or receiver,one alert dialog should appear with cellphone number.it all works fine but issue is alert dialog is also appearing when i am getting call,but i only want only after disconnection,i don't know what is mistake i am making following is my code..can any one help? public class MyCallReceiver extends BroadcastReceiver { private String incomingNumber; @Override public void onReceive(Context context, Intent intent

How to get alert dialog only after disconnect call?

我是研究僧i 提交于 2020-01-07 08:01:12
问题 In my app i am doing one thing that,when the call is disconnected by caller or receiver,one alert dialog should appear with cellphone number.it all works fine but issue is alert dialog is also appearing when i am getting call,but i only want only after disconnection,i don't know what is mistake i am making following is my code..can any one help? public class MyCallReceiver extends BroadcastReceiver { private String incomingNumber; @Override public void onReceive(Context context, Intent intent

Run BroadcastReceiver in the background and when device is alseep?

蹲街弑〆低调 提交于 2020-01-07 06:42:52
问题 I have a simple BroadcastReceiver set up to do something when the user gets an incoming SMS. But I need it to run in the background and when the device is asleep. So would I use a Service that starts the BroadcastReceiver ? If so, can someone give me some pseudo-code? And how would this work if the device is asleep? 回答1: I have a simple BroadcastReceiver set up to do something when the user gets an incoming SMS. OK. But I need it to run in the background and when the device is asleep. Not

Android - SMS - intent-filters priority listing

时光总嘲笑我的痴心妄想 提交于 2020-01-07 05:41:20
问题 I was wondering if it is possible to find a list that includes all the receivers associated to a certain action. For example I have the following receiver that executes everytime that an SMS is received: <receiver android:name=".SmsReceiver" android:enabled="true"> <intent-filter android:priority="101"> <action android:name="android.provider.Telephony.SMS_RECEIVED" /> </intent-filter> </receiver> So with the priority="101" it´s executed even before than the default message service in Android.

Save Alarm after app killing

余生颓废 提交于 2020-01-07 03:08:15
问题 Code that starts AlarmManager. AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, AlarmManagerBroadcastReceiver.class); PendingIntent pi = PendingIntent.getBroadcast(context, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT); Its work fine, but when I kill my app in task killer, I lost my alarm. How to solve this problem? Here full code: 1. Its alarm reseiver: public class AlarmManagerBroadcastReceiver extends

Create reminder in android app

孤街醉人 提交于 2020-01-06 14:18:31
问题 I am trying to create a weekly reminder in my app. For this I am using AlarmManager. Here is the code generating alarm pendingIntent = PendingIntent.getBroadcast(SettingsActivity.this, 1234567, new Intent(SettingsActivity.this, WeeklyReminder.class), 0); AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.add(Calendar.SECOND, 30); long updateFreq = 30*1000;//24*60

Create reminder in android app

时光毁灭记忆、已成空白 提交于 2020-01-06 14:18:05
问题 I am trying to create a weekly reminder in my app. For this I am using AlarmManager. Here is the code generating alarm pendingIntent = PendingIntent.getBroadcast(SettingsActivity.this, 1234567, new Intent(SettingsActivity.this, WeeklyReminder.class), 0); AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.add(Calendar.SECOND, 30); long updateFreq = 30*1000;//24*60