android-broadcast

How to send a data from a broadcast receiver to fragment?

本秂侑毒 提交于 2019-12-11 05:20:02
问题 How to send a data from a broadcast receiver to fragment? Here I want to send the phonenumber (OriginatingAddress) to another fragment. public void onReceive(Context context, Intent intent) { Bundle intentExtras = intent.getExtras(); if (intentExtras != null) { Object[] sms = (Object[]) intentExtras.get(SMS_BUNDLE); String smsMessageStr = ""; for (int i = 0; i < sms.length; ++i) { SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) sms[i]); String smsBody = smsMessage.getMessageBody()

Android foreground service being killed under certain conditions

心已入冬 提交于 2019-12-11 04:14:34
问题 I have a Service used for playing audio. It is created with START_STICKY , and calls startForeground() when it is told to play music, and stopForeground() when it is told to stop playing music. The service continues to run fine and play music, even after the app is swiped out of the task manager on 4.2.1. However, the service is inexplicably killed if the app is swiped out and the app's home/lockscreen widget is interacted with or if I try to sendBroadcast() within the service. I cannot find

INSTALL_REFERRER not received on production

我的未来我决定 提交于 2019-12-11 02:48:50
问题 I'm not getting install referrer received on application installed from the play store. Below is my Androidmanifest.xml shows receiver which is inside <application> tag too. <receiver android:name="com.usplnew.getreferrer.CustomReceiver" android:exported="true" > <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER" /> </intent-filter> </receiver> And below is code for Receiver public class CustomReceiver extends BroadcastReceiver { @Override public void onReceive

How to detect headset button double click in HTC phones with broadcast receiver?

浪尽此生 提交于 2019-12-11 02:18:18
问题 I'm developing a headset button controller and use a broadcast receiver for detecting headset button presses. ((AudioManager) getSystemService(AUDIO_SERVICE)).registerMediaButtonEventReceiver(new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName())); onReceive method: public void onReceive(Context context, Intent intent) { String intentAction = intent.getAction(); if (!Intent.ACTION_MEDIA_BUTTON.equals(intentAction)) { return; } KeyEvent event = (KeyEvent) intent

Android: I need to delay a Notification

假装没事ソ 提交于 2019-12-11 02:10:00
问题 I've create a broadcast receiver that listen to the android.provider.Telephony.SMS_RECEIVED event and creates its own notification. I also use the same receiver in the app to update the activities when an sms is received using a callback. The problem is that the sms app notification event is dispatched after my notification, so when I update the sms is not preset in content://sms I would like to delay my notification if it's possible, can't find how to do it. here's the code: public class

Raising a toast when Power Button is pressed twice

北战南征 提交于 2019-12-11 02:03:34
问题 What i am trying to do is ,double clicking the power button will raise a toast "Sending Message", doesn't matter if screen is On or Off.What i have done is , i have recorded the time duration of the clicks on power button & If the difference b/w the current click and previous click duration is less than a 1sec, then it will raise the toast. But its raising the toast on the single click also. Please Help me out 1.MainActivity.java public class MainActivity extends Activity { @Override public

How to start hidden app by using call dialer(keypad) using Android code? [closed]

血红的双手。 提交于 2019-12-10 14:32:37
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 years ago . I want to start my app which is a hidden app by dialing certain predfined number by me programatically ,for eg *#*#111#*#* .I open the dialer and input *#*#111#*#* .Then My app receives the broadcast and starts.Which broadcast should I listen? 回答1: You should input number *#*#xxxx#*#* , say, *#*

How to receive UDP broadcasts on an Android device

你离开我真会死。 提交于 2019-12-10 11:55:43
问题 How can I make my Android phone receive UDP broadcasts? At the moment i am testing my app using a tablet and a phone. The problem is that only the tablet can work as a server, not the phone. The scenario of my app where the problem is: - Client is sending broadcast in a local network - Server is receiving this broadcast and sending a response to the client directly I am pretty sure I think I know what's wrong as the app only works when the server is running on the tablet and that is that the

Broadcast action for WIFI change

﹥>﹥吖頭↗ 提交于 2019-12-10 04:53:05
问题 In my application I have to get notified whenever the device connects or disconnects from a WIFI network. For this I have to use a BroadcastReceiver but after reading through different articles and questions here on SO I'm a bit confused which Broadcast action I should use for this. In my opinion I have three choices: SUPPLICANT_CONNECTION_CHANGE_ACTION NETWORK_STATE_CHANGED_ACTION CONNECTIVITY_ACTION To reduce resources I really only want to get notified whenever the device is CONNECTED to a

How to differentiate the connected bluetooth device in android programmatically?

丶灬走出姿态 提交于 2019-12-10 02:58:47
问题 Whether it is a bluetooth headset or mobile phones? how to differentiate the bluetooth headset and bluetooth enabled android device in android code. I am developing a small application,in that I have a feature of blocking the data transfer via bluetooth but it need to allow communication via bluetooth headset. I referred the examples and codes in that they suggest me to pair/unpair the bluetooth devices only. Android: How to pair bluetooth devices programmatically? or else get all connected