FAQ Database Discussion Community


Issue receiving SMS in KitKat

android,android-broadcast,smsmanager
I am having a little issue with the new SMS semantics introduced in KitKat (4.4) : https://developer.android.com/about/versions/android-4.4.html#SMS I have the following situation with an app I developed in Jelly Bean : The system receives an SMS and I hook into that with a broadcast-receiver listening to android.provider.Telephony.SMS_RECEIVED. I check if...

AlarmManager - Am I doing it right?

android,broadcastreceiver,android-service,alarmmanager,android-broadcast
I had setup AlarmManager in my MainActivity class. A class called AlarmReceiver gets fired up for every set interval of time. I have to perform an operation when that class is fired up. That code is in in another class Parsing.java Now in AlarmReceiver.java, I'm doing this : public class...

“Unable to create service” error on alarm set

android,android-intent,android-pendingintent,android-broadcast,android-alarms
I have a problem when i'm trying to set an alarm : My service "SetNotifications" is called by a broadcast receiver called "BroadcastReceiverCalendar". The service "SetNotifications" set multiple alarms. My application crash on the last line, see error code bellow. Here is the code of my alarm setup : Intent...

How to unregister receiver attached to LocalBroadcastManager?

android,android-broadcast
How to unregister receiver attached to LocalBroadcastManager? I tried unregisterReceiver(broadcastReceiver); but it gave me an exception java.lang.IllegalArgumentException: Receiver not registered: This is my code @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); init(); locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiverCancelPd, new...

Update widget when preferences changed using custom broadcast

android,widget,android-broadcast
I need to update my app's widget every time the settings are changed by the user. I have a settings activity: import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; public class SettingsActivity extends Activity implements SharedPreferences.OnSharedPreferenceChangeListener { public static final String customIntent = "CUSTOM_SETTINGS_CHANGED"; @Override protected void onCreate(Bundle savedInstanceState) {...

How to have BroadcastService communicate with Activity?

android,android-intent,notifications,android-broadcast
I'm trying to get push notification working in my Android app, using parse.com's push notification service. They implement a Broadcast receiver, which I am extending in my own class: public class MyPushBroadcastReceiver extends ParsePushBroadcastReceiver { @Override protected void onPushReceive(Context context, Intent intent) { JSONObject data = getDataFromIntent(intent); [...] super.onPushReceive(context, intent);...

Android AlertDialog won't dismiss when aux cord is unplugged

android,android-alertdialog,android-broadcast
I want an AlertDialog message to appear when the user plugs in an aux cord. I want the alert message to disappear when the user unplugs the auxiliary cord. I don't want the user to able to get rid of the AlertDialog message until he/she unplugs the aux cord. So...

Issue in open my application from browser url in android

php,android,browser,android-broadcast,deep-linking
Hello friends i wnat to open my application form browser url so in my menifest file below is my code <activity android:name=".Registration" android:exported="true" > <intent-filter> <data android:scheme="rentalandroid"/> <category android:name="android.intent.category.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <action android:name="android.intent.action.VIEW" /> </intent-filter> </activity> and i...

Share info between two processes - what's the safest way?

android,process,sharedpreferences,android-broadcast
I have an app with two processes - the MainActivity and a background Service. I need the same information in both, and this info comes from my server (a JSON response). I was loading this JSON from both processes, but as this JSON may get bigger it's pretty inefficient to...

Android - How to trigger a Broadcast Receiver to call its onReceive() method?

android,android-intent,broadcastreceiver,android-manifest,android-broadcast
I have scheduled alarm for my application. I have implemented broadcast receiver to be triggered once the alarm time reaches. How to manually call broadcast receiver to execute the code inside of onReceive method without replicating the code twice. I thought of having the code in utility singleton call and...

How can I use more than one Broadcast in activity?

java,android,android-broadcast
[Service.java] Intent intent = new Intent(); intent.setAction("sample"); intent.putExtra("timer_real", hms); sendBroadcast(intent); [Activity.java] public void onResume() { super.onResume(); IntentFilter filter = new IntentFilter(); filter.addAction("sample"); registerReceiver(sn_english, filter); } public void onPause() { super.onPause(); unregisterReceiver(sn_english); } BroadcastReceiver sn_english= new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { String timer_real = intent.getStringExtra("timer_real");...

Socket listener in IntentService

android,sockets,android-broadcast,android-intentservice
In my program, I am receiving data via socket in an IntentService class and then sending the same as a broadcast to activity. Activity processes the input and prepares an output. while (true) { socket = serverSocket.accept(); //Read data from socket //Publishing as a broadcast } Now my question is...

Do BroadcastReceiver, Service, and Activity share Application object?

android,android-activity,android-service,android-broadcast,android-context
I have among others the following components: a BroadcastReceiver registered in Manifest a STICKY Service normally started by boot complete which processes Intents from the above BroadcastReceiver an Activity which binds to the Service (starting it if for some reason does not exist) Under which circumstances do these components share...

Any further documentation/tutorial/example of sendBroadcastAsUser?

android,android-intent,android-broadcast
The only documentation on sendBroadcastAsUser says this: sendBroadcastAsUser(Intent intent, UserHandle user, String receiverPermission) Version of sendBroadcast(Intent, String) that allows you to specify the user the broadcast will be sent to. But I've not been able to find any examples of how the user is specified, or how you would set...

BroadcastReceiver for CONNECTIVITY_CHANGE, WIFI_STATE_CHANGED and PROVIDER_CHANGED

android,android-manifest,android-broadcast
I have a MyBroadcastReceiver setup like so: <receiver android:name=".MyBroadcastReceiver"> <intent-filter> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> <action android:name="android.net.wifi.WIFI_STATE_CHANGED" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.PROVIDER_CHANGED" /> </intent-filter> </receiver> As you can see it "listens" for CONNECTIVITY_CHANGE, WIFI_STATE_CHANGED and PROVIDER_CHANGED. The first two are working great,...

startActivity not working when calling from BroadcastReciever

android,android-activity,android-notifications,android-broadcast
I have a notification and when I select, it sends a Broadcast to a BroadcastReciever using a PendingIntent. In the onReceive I start a new Activity. However, if I remove my app from recent apps opened (or the notification sit in the draw for a long time) this scenario occurs:...

Android - Custom action in Broadcast Intent

android,android-intent,broadcastreceiver,intentfilter,android-broadcast
I am trying to allow user to post comment when he is offline such that whenever wifi/internet is turned on his comment will be posted.Fot that I am using BroadCastReceiver.But the issue i am having is that it is never going inside if (intent.getAction().equals("commentpost")) if i try switching on wifi...

How to know when the services has ended

android,android-service,android-broadcast
I want know when the service has ended, so I use BroadcastReceiver. My service name is CheckNuevosAvisosIntentServices and I launch it in main.java (onCreate method) as: Intent msgIntent = new Intent(Main.this, CheckNuevosAvisosIntentService.class); msgIntent.putExtra("iteraciones", 1); startService(msgIntent); My manifest inside application tag. <!-- Services --> <service android:name="com.kirolm.instalacionesdep.services.CheckNuevosAvisosIntentService" /> In another fragment (HomeFragment)...

AlarmManager is discarded when application is cleared from background

android,broadcastreceiver,alarmmanager,android-pendingintent,android-broadcast
This is how I am creating an alarm. When the app is still running in background the alarm is fired. but when it is cleared from the recent apps, the alarm is getting discarded. I am registering a new receiver and providing a unique action for differentiation between two alarms....

INSTALL_REFERRER not received before application launched

android,android-intent,broadcastreceiver,android-broadcast
I want to catch INSTALL_REFERRER intent at my own receiver. I implemented receiver public class InstallReferrerReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Log.d("Broadcast", "RECEIVED!"); } } and add at Manifest <receiver android:name=".receiver.InstallReferrerReceiver" android:exported="true"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER"/> </intent-filter> </receiver> When i want to test receiver, i...

Alarm receive don't work

android,android-intent,android-service,android-pendingintent,android-broadcast
I'm making an alarm receiver, but the alarm is not triggered. This is my code : Start alarm in MainActivity : private void setupAlarm(){ Intent intent = new Intent(this, com.logdata.AlarmReceiver.class); PendingIntent pIntent = PendingIntent.getService(this, 0, intent, 0); AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); manager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,SystemClock.elapsedRealtime() + 1, 1000, pIntent); Log.e("setupAlarm", "Setup alarm...

How to identify that a user came from laucher or from shortcut of my Android App?

android,android-intent,shortcut,android-pendingintent,android-broadcast
I am developing an android app where i am creating a shortcut from HomeActivity and from that shortcut i move back to HomeActivity. My problem is i want to send some url in shortcut and want to get back that url when user come from shortcut to HomeAtivity. Here's code...

Android reconnect to bluetooth device if connection lost

java,android,bluetooth,android-broadcast,android-bluetooth
My phone is connecting to a bluetooth device and it works normally. It connect and the connection holds. I can change orientation, have my app in the background, I can close app and when I turn it back on it will automatically connect. But from app users I get some...

Android - check internet and Wi-Fi connectivity with the help of BroadcastReceiver?

java,android,android-intent,android-wifi,android-broadcast
I want to check internet and Wi-Fi connectivity. I have implemented the code. But in this code the problem is, when I activate Wi-Fi in my device then it continuously toasts "Wi-Fi disconnected" and "Internet Connected" 3-4 times and then at last times it toasts "Wi-Fi connected" and then my...

Android simulating play/pause button

android,android-intent,android-broadcast,keyevent,android-context
I'm trying to make my application open up Google Play Music and then simulate a play/pause command. My application is able to start Google Play Music successfully, but the downIntent and upIntent KeyEvents are never broadcast. I suspect this is because calling the method just invokes the method on my...

Will Intents started by AlarmManager retain its objects between runs?

java,android,android-intent,android-broadcast,android-alarms
I have an app that uses an AlarmManager to do a task regularly. From the Intent that is called by the AlarmManager I access the application to get access to shared data. Application foo = getApplication(); I then use the foo object both for reading and writing data. Most of...

Android - Difference between Broadcast Receiver and Service

android,android-intent,broadcastreceiver,android-service,android-broadcast
I am wondering, what would be the difference between registering broadcast receiver statically in the manifest and starting a service? Both will run even if the app is in the background and it seems to me that receiver is much less complicated to code. Am I missing something here?

Android block outgoing calls issue

android,android-broadcast
I want to block out going calls based on some logic. I am using below code public class OutgoingCallReceiver extends BroadcastReceiver { private OutgoingCallListener customPhoneListener = null; public static boolean check = true; @Override public void onReceive(Context context, Intent intent) { String originalNumber = intent .getStringExtra(Intent.EXTRA_PHONE_NUMBER); TelephonyManager telephony = (TelephonyManager)...

Android - Passing simple string over Wi-fi?

java,android,android-wifi,android-broadcast,android-file
I have Wi-fi direct demo. In that we can transfer any image files to other devices. When another device get connected and it shows to send image from gallery. And at other side it shows sent image. But I want to send a simple string and at other side I...

How to send data from IntentService to Non-Activity class

android,android-service,android-broadcast,intentservice
I have two Service class. one is WebsocketService(extends Service) to manage Websocket related function and SocketMessageProcessing(extends IntentService) to process response Received in WebSocketService. From Non-Activity(SocketImpl) class I am successfully able to send data to WebsocketService. But I am having trouble in sending response back to SocketImpl class from SocketMessageProcessing class....

How does Starbucks show a UI on Android devices when near store?

android,android-broadcast,android-networking
I am a fairly new Android developer. One thing that I noticed is that when I walk near/inside a Starbucks store, my Android device shows the following: Question: How does this UI render automatically onto my mobile device when I am near/inside the store? Does this UI appear because I...

Androidmanifest build error about receiver within a service

android,android-intent,android-studio,android-service,android-broadcast
I'm trying to build an application with gradle>assembleRelease on AndroidStudio but I have an error: Error:(31) Error: The element must be a direct child of the element [WrongManifestParent] the concerned code is : <service android:enabled="true" android:name="com.example.xx.ServiceCalendar"> <receiver android:name="com.example.xx.ServiceCalendar"> <intent-filter> <action android:name="ALARM_DL" /> <action android:name="ALARM_PARSE" /> <action android:name="ALARM_NOTIF" /> </intent-filter>...

Android onResume not called after onNewInetent

android,android-intent,android-activity,android-broadcast,onresume
I have a BroadcastReceiver which should launch activity: @Override public void onReceive(Context context, Intent intent) { if (wakeLock == null) { PowerManager pm = (PowerManager) ApplicationScreen.instance.getApplicationContext() .getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); } if (!wakeLock.isHeld()) { wakeLock.acquire(); } try { if (ApplicationScreen.instance != null) { Intent dialogIntent = new Intent(context, MainScreen.class);...

Unable to send broadcast to closed app

android,android-intent,android-broadcast,android-lvl
We've developed an app that requieres a second app (pro key app) to validate its license. The main (free app) request, via broadcast, to the pro key app to check the license. The problem is that when the pro key app is closed it never receives the broadcast sent by...

Android: Reminder concept with Alarm Manager

android,sqlite,alarmmanager,android-broadcast
I tried to make reminder application for Android, followed tutorial from this website Set Notification for Specific Date. Basically it used Alarm Manager to create a reminder. This code used to call alarm manager and show notification on specific date. reminderClient.setAlarmForNotification(calendar, uniqueid, interval); I save all of the reminder in...

How to track sent messages (SMS) in android?

android,sms,broadcastreceiver,message,android-broadcast
I am developing an Android application which has one of it's features as to detect any messages (SMS) sent by an app to any number. For this I want to keep track of sent messages. I want to check the message as and when it is sent. I know there...

How to detect change in time each second in Android?

android,android-intent,android-wear,android-broadcast,watch-face-api
I am creating a custom watch face for android by following this tutorial. I have implemented broadcast receiver to detect change in time as follows: Inside my activity I have static block to filter following intents: static { intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_TIME_CHANGED); intentFilter.addAction(Intent.ACTION_TIME_TICK); intentFilter.addAction(Intent.ACTION_TIMEZONE_CHANGED); } My receiver class: public...

Responding to broadcast message from activity

android,broadcastreceiver,android-broadcast
I have an intent service that broadcasts a message based on user action and my activity is registered to receive the message. Now, after the activity receives the message, I want my activity to respond to it depending on the message passed. I have the below questions: 1. Will the...

Broadcast result is always zero

android,android-broadcast
I'm trying to create an external broadcast service which sends a number. A client (external application) trying to send a request to my service and the service sends back a number. I registered my service and broadcast resiever in AndroidManifest.xml: <service android:exported="true" android:enabled="true" android:name=".MyService"/> <receiver android:exported="true" android:enabled="true" android:name=".MyStartServiceReceiver"> <intent-filter> <action...

Service Intent Service or Receiver

android,android-broadcast
My solutions should send a http request and process it's response on every location update. Also it should survive after starting app is killed. I am struggling to pick one of the following designs for this task: Create a location broadcast listener on a Service. Crete an Intent Service which...

Separate thread background service with communication with activity in Android application

android,multithreading,broadcastreceiver,android-service,android-broadcast
I'm an experienced Web-developer, but I'm very new to the Android SDK and Java. I have a conceptual question regarding background operations and multithreading in Android application. I'm going to develop an app which will has a constantly-working background service (it will communicate with remote server over HTTP). Also, I'm...

Broadcast receiver in a service doesn't receive alarm signal

android,android-intent,android-service,android-broadcast,android-alarms
Here is my problem, I have a service started on boot or on the launch of the application, this service start an alarm which download a file every x minutes. The problem is that the broadcast receiver doesn't seems to receive anything. here is the concerned code: @Override public int...