broadcastreceiver

Android notifications multiple times

前提是你 提交于 2019-12-06 14:10:57
I have notifications that remind user to take the medicine. When I add new times for taking medicines, for example, at 9:00 pm and 9:01 pm, only last notification is active. Here is my code: AddTime.java: (part) Cursor cursor2 = sqdb.rawQuery("SELECT Name FROM Medicine WHERE _id = " + mId, null); while(cursor2.moveToNext()) { med = cursor2.getString(cursor2.getColumnIndex("Name")); } //med - Name of medicine String sql = "SELECT _id FROM Time WHERE mId = "+mId+" AND Year = "+year+" AND Month = '"+_month+"' AND Day = "+_numDay+" AND Week = '"+_week+"' AND Hour = "+_hour+" AND Minute = "+_min+"

Exception when sending broadcast to ComponentInfo

北城余情 提交于 2019-12-06 14:04:19
I have a receiver for Google cloud message, it's registered in AndroidManifest.xml: <receiver android:name="com.app.android.push.HSPushReceiver" android:permission="com.google.android.c2dm.permission.SEND" android:enabled="true" android:exported="true"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <action android:name="com.google.android.c2dm.intent.REGISTER" /> <category android:name="com.app.android" /> </intent-filter> </receiver> I can receive message when the app is in foreground or

How to run BroadcastReceiver after every minute?

末鹿安然 提交于 2019-12-06 13:55:31
I am developing an application to monitor the network after every minute. i am using a BroadcastReceiver for this. I want to execute the BroadcastReceiver after every minute. How can I do it? can i use Thread.sleep() in BroadcastReceiver? Is it okay to continuously keep running BroadcastReceiver in android? BroadcastReceievers are designed to run only when some broadcast is received (System broadcast or user defined broadcast). In case you want to run some code every minute, you can create a service and schedule it for every minute run using an Alarm Manager. You can start the service from

Start Activity from a Broadcast Receiver

你说的曾经没有我的故事 提交于 2019-12-06 13:52:25
I've got the following scenario for Android: I have an app that when launched starts a service . That service checks a url every 30 minutes. If it gets a specific response, it sends a Broadcast which the app receives and processes. That scenario is working great for me. I'd also like my service to continue running after the user has stopped running the application (app out of foreground.) Which I've got working as well. The problem that I'm facing is that when the Activity receives the Broadcast message, I can't get the Activity to move back to the foreground . I've tried various combinations

Detect call state change in VOIP Android apps

孤人 提交于 2019-12-06 13:35:10
Is there a way to detect the beginning/ending of voice calls in apps such as Google Hangouts / Skype? (I know this is a shot in the dark, but I was wondering if anyone researched this option). I'm interested in something like Android's receivers for the android.intent.action.PHONE_STATE and the android.intent.action.NEW_OUTGOING_CALL actions Skype broadcast: com.skype.android.CONVERSATION_LIVE_STATE There u can read: com.skype.live_identity -> ur friend com.skype.live_status -> RINGING_FOR_ME or STARTING or NONE com.skype.account -> your account 来源: https://stackoverflow.com/questions/26795814

I need to implement Notification Reminder in my android app

送分小仙女□ 提交于 2019-12-06 12:41:28
问题 My Requirment: I want my application to show a reminder notification on every Friday @ 8 am I have used AlarmManager, BroadcastReceivers to implement my reminder notification. The problem I am getting is, When I set notification time using current system time and Add 2 minutes in it... It works perfectly when I use it in this way, it trigger my notification exactly after 2 minutes. But, When I use calender instance to set notification time at specific time of any day, it trigger my reminder

sending sms to multiple contacts using loop

我们两清 提交于 2019-12-06 12:40:07
问题 I am working on an android sms application.I have to send sms to multiple contact.There is method available to send sms to multi contacts so i used for loop.The following is my code. for (int i = 0; i < to_nums.size();i++) { sendSms(to_nums.get(i), snd_txt.getText().toString() ); } public void sendSms(final String phoneNumber, final String message){ String SENT = "SMS_SENT"; String DELIVERED = "SMS_DELIVERED"; PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT), 0);

Listening and reciveing specific SMS message?

孤街浪徒 提交于 2019-12-06 12:37:58
Ok i Have this broadcast reciver for Listening incoming SMS public class SmsReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { //---get the SMS message passed in--- Bundle bundle = intent.getExtras(); SmsMessage[] msgs = null; String str = ""; if (bundle != null) { //---retrieve the SMS message received--- Object[] pdus = (Object[]) bundle.get("pdus"); msgs = new SmsMessage[pdus.length]; for (int i=0; i<msgs.length; i++){ msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]); str += msgs[i].getMessageBody().toString(); } } try { File root =

Query supported languages for SpeechRecognizer using BroadcastReceiver intent

天大地大妈咪最大 提交于 2019-12-06 12:27:35
I'm having trouble querying for supported languages using the SpeechRecognizer.ACTION_GET_SUPPORTED_LANGUAGES. private void queryLanguages() { Intent i = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS); sendOrderedBroadcast(i, null); } Now, I know it says the BroadcastReceiver is specified in RecognizerIntent.DETAILS_META_DATA, but I'm not sure as to how I can access that. So basically what I'm asking is how do I create an Intent to retrieve the available languages data? Reno This is how it is done: Intent intent = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS); context

Geofence events not always called

与世无争的帅哥 提交于 2019-12-06 11:53:36
问题 This is how I add my geofences: public void setGeofenceRequest(Location location) { if (geofences == null) { geofences = new ArrayList<Geofence>(); } geofences.add(new Geofence.Builder() .setRequestId("3") .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_EXIT) .setCircularRegion( location.getLatitude(), location.getLongitude(), PSLocationService.getInstance(context).kPSGeofencingDistanceMedium) .setExpirationDuration(Geofence.NEVER_EXPIRE) .build()); Intent intent = new Intent(context,