broadcastreceiver

NFC broadcastreceiver problem

狂风中的少年 提交于 2019-12-04 15:51:09
问题 I want my app to listen to nfc tags only when is activated. For this I tried to register an nfc listener as following, without any success. IntentFilter filter = new IntentFilter("android.nfc.action.TECH_DISCOVERED"); registerReceiver(nfcTagListener, filter); BroadcastReceiver nfcTagListener = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) { Tag tag = intent

Incoming call broadcast receiver

一笑奈何 提交于 2019-12-04 15:49:49
问题 I have registered incomingCall broadcast receiver, and it works fine, but I need receiver when the call is established (or rejected). What I actually need is something to notify me when the user press 'Answer' or 'Reject' call. 回答1: You can override your onReceive method of BroadcastReceiver as below public void onReceive(Context context, Intent intent) { String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE); if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) { //Phone is

How to implement 'pop up box' in Android similar to Viber (when a message is received)

醉酒当歌 提交于 2019-12-04 15:44:30
I work as a junior Android developer and the client has requested the following: "Make research about implementation of pop up box, while application is in background. Thea idea is always when there is notification to show in notification panel, also to be shown in pop up box." (Viber was taken as an example of this) I know how to work with activities and fragments and views in Android, but I don't know how to even google about this so I thought someone could point out a tutorial or just say if there is a word for this technique so I can study it. When a new message is received (Broadcast

How to Know which Sms is sent/delivered from Android BroadcastReceiver?

一曲冷凌霜 提交于 2019-12-04 15:42:19
Hi Guys I have made simple app to send multiple SMS on android, and I cannot find known which sms is Sent/Delivered, because the delivery notification does not tell for which it is. here is my code : this.destination = data[0]; this.body = data[1]; PendingIntent piSend = PendingIntent.getBroadcast(aCtx, 0, new Intent(Cons.SMS_SENT),0); PendingIntent piDelivered = PendingIntent.getBroadcast(aCtx, 0, new Intent(Cons.SMS_DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(destination, null, body, piSend, piDelivered); Then I use broadcast receiver to get

Calling the finish() method of an Activity from a BroadcastReceiver

时光毁灭记忆、已成空白 提交于 2019-12-04 15:32:04
I have 2 Activities (Activity1, Activity2) and a BroadcastReceiver class Assume that we are now on Activity2, where I set up an AlarmManager to run at a specific time. Is there a way to call the finish() method of Activity2 within the onReceive() of the BroadcastReceiver? My goal is to return to Activity1 from Activity2 without starting a new Intent in onRecieve(). Note: The BroadcastReceiver class is not registered within the Activity of Activity2. It is registered in the AndroidManifest.xml. You can call finish() on the onReceive method. Do remember to unregister your listener on the

Register a broadcast receiver from a service in a new thread

萝らか妹 提交于 2019-12-04 14:58:38
I have a broadcastreciever which start a long operation (uploading process). In the code of a service started from the Activity class, I need to register this receiver in a new thread. I have checked this post Are Android's BroadcastReceivers started in a new thread? but I need a more concrete example about using Context.registerReceiver(BroadcastReceiver receiver, IntentFilter filter, String broadcastPermission, Handler scheduler) Actually I need to know how to create a new thread from a service and to register the receiver and attached to this thread. Thank you very much. RA In your service

Wallpaper change event

谁都会走 提交于 2019-12-04 14:47:48
Can I get a wallpaper changed event in a broadcast receiver? I need to detect if the user changed the wall paper. How could I do it? What I am doing is this: I have an app that changes wallpaper automaticly. If the user changes it manually using a different aplication I would like to notice it and ask the users if he/she wants to add that new wallpaper to the list in my application There is only a broadcast for when a wallpaper image changes: http://developer.android.com/reference/android/content/Intent.html#ACTION_WALLPAPER_CHANGED To do what you want, you will need to have more logic to use

How to detect new apps in an Android device

老子叫甜甜 提交于 2019-12-04 14:02:51
问题 I want to detect when the user installs or deletes an app, and I didn't find a BroadcastReceiver that does this. In my app, I get the information about the installed apps with the class PackageManager , but I don't want to scan the apps periodically. Is there any BroadcastReceiver that does this? Or any ContentObserver ? Is it possible to get a notification that an app has been installed or removed? 回答1: You can register a BroadcastReceiver using Intent.ACTION_PACKAGE_ADDED (and also Intent

How to get contact name when receiving SMS

丶灬走出姿态 提交于 2019-12-04 13:40:12
I have the following code to receive an SMS and I am trying to get the contact name. package com.example.smsTest; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.ContactsContract; import android.provider.ContactsContract.PhoneLookup; import android.telephony.SmsMessage; import android.widget.Toast; public class SmsReceiver extends BroadcastReceiver { private SQLiteAdapter mySQLiteAdapter; @Override public void onReceive(Context

ACTION_HEADSET_PLUG broadcast delay

这一生的挚爱 提交于 2019-12-04 13:34:38
问题 I have my own BroadcastReceiver instance for Intent.ACTION_HEADSET_PLUG action. There is about 1-2 seconds delay between actual physical unplugging a headset and a moment when my BroadcastReceiver is notified about that. IntentFilter filter = new IntentFilter(Intent.ACTION_HEADSET_PLUG); filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY - 1); registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // my code here } }, filter); Any ideas