broadcastreceiver

How to know in BroadcastReceiver if App is running on foreground?

空扰寡人 提交于 2019-11-27 17:57:29
问题 I am working in application that needs make a synchronization every night. I use Alarm Manager that calls a BroadcastReceiver at the hour that I want. The problem is that I cant make a synchronization if the application is running in foreground to avoid losing data. So I need to know in Broadcast Receiver if the app is running in foreground to cancel this synchronization. I tried solutions that I found in StackOverflow: Checking if an Android application is running in the background But this

Why BroadcastReceiver works even when app is in background ?

对着背影说爱祢 提交于 2019-11-27 17:38:23
I am checking Internet connectivity in my app using BroadcastReceiver and I show an alert dialog if the connection is lost. It works fine. But my problem is that BroadcastReceiver works even if my app is in backgroung. So dialog pops up when internet connection is lost even if user is in some other app. This is totally ruining my app. Has anyone got any idea how to restrict Broadcast receiver in the app only? Here is my BroadcastReceiver : public class ConnectivityChangedReceiver extends BroadcastReceiver{ @Override public void onReceive( Context context, Intent intent ) { ConnectivityManager

How to set permissions in broadcast sender and receiver in android

狂风中的少年 提交于 2019-11-27 17:21:15
How do we specify in broadcast sending application that which application can receive this broadcast, and in receiving application that which particular application has the permission to send broadcast to its broadcast receiver... I am new to android..I read the documentation etc on internet but couldn't find the syntax to specify these permissions. use an intent filter in receiver tag in manifest <receiver android:name="Your receiver" android:enabled="true" android:exported="false" > <intent-filter> <action android:name="action"/> <category android:name="category" /> </intent-filter> <

How to block an incoming message in android?

偶尔善良 提交于 2019-11-27 17:01:09
问题 I am trying to develop an app in android which blocks an incoming sms. I have set the priority but its not blocking the incoming sms. I have used this.abortBroadcast() also but no result. import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.telephony.gsm.SmsMessage; import android.widget.Toast; @SuppressWarnings("deprecation") public class SmsReceiver extends BroadcastReceiver { @Override public void

Android - [Xoom/Honeycomb] application without LAUNCHER activity does not work

让人想犯罪 __ 提交于 2019-11-27 16:44:38
问题 I have an application without launcher activity that works properly from Android 1.5 to Android 2.3.4. It is started by my broadcast receiver. However, on Honeycomb (Motorola Xoom), my broadcast receiver doesn't work at all (it does not catch any intents). If I add launcher activity to my manifest: <activity android:label="@string/app_name" android:name="com.myapp.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent

Dynamically register/unregister a broadcast receiver in android

一笑奈何 提交于 2019-11-27 16:40:06
问题 I want to dynamically register and unregister my receiver class with the broadcast: "android.net.wifi.STATE_CHANGE" This works very well if I do this in the manifest. But this makes it static. I want to do it dynamically in the activity class. What is its correspondent command in the activity class? This is what my code is... and I am getting a problem because of registering and unregistering(multiple times) my receiver(which is starting a service). public class startScreen extends Activity {

Block sent SMS from being logged in default messaging app

拟墨画扇 提交于 2019-11-27 16:30:49
I have an auto reply sms Android application I built and I don't want the auto reply (sent sms) to show in the default messaging app. I have searched and searched and couldn't find an answer. Is there a way to bypass writing the sent sms into the default messaging app? Here my BroadcastReciever I am using to get the data and send out the message public class SmsReceiver extends BroadcastReceiver { ParseUser user = ParseUser.getCurrentUser(); // Auto reply message composed of the current reply and url from that business String msg = user.getString("myCurrentReply") + " " + user.getString(

cannot cancel the current alarm in Android

半腔热情 提交于 2019-11-27 16:26:46
I am new to Android. Here, I am not getting any errors ,While debugging the stopAlarm() method debugger crossed all the lines but the AlarmReceiver is not get called . can anyone help me to fix it . Update : AlarmActivity.java public void stopAlarm(Context context) { Intent intent = new Intent(context,AlarmReceiver.class); intent.setAction("ALARM_OFF"); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, mAlarmId, intent,0); AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE); alarmManager.cancel(pendingIntent); } The problem is here, in

Android broadcast receiver not working

拥有回忆 提交于 2019-11-27 16:17:59
问题 I try to get a broadcast receiver working. Should be as simple as possible, I have my manifest like this: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mytest.intentRec" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> <activity android:name=".mainAct" android:label="@string/app_name"> <intent-filter> <action

Can't get receiver when the app uninstall

我的未来我决定 提交于 2019-11-27 15:48:00
I refer this information. I write the same program, but I can't get any log info when I click uninstall button . I attach my code below. Have anyone know what's problem in this code? I want to do something when use click uninstall button. Maybe like turn on browser, etc. Have any one can give me a hand? The problem has confused me for a long time. My AndroidManifest: ... <uses-permission android:name="android.permission.GET_TASKS" /> <uses-permission android:name="android.permission.RESTART_PACKAGES"/> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="