broadcastreceiver

Starting the application from a BroadCastReceiver (NEW_OUTGOING_CALL doesn't always work)

百般思念 提交于 2019-12-24 11:36:57
问题 Well, I've written an application that starts by dialing an specific number, I have used NEW_OUTGOING_CALL (a broad cast receiver) to catch the dial event. So far the broad cast receiver on my AndroidManifest.xml is like the following code: <receiver android:name=".CustomBroadCastReceiver"> <intent-filter> <action android:name="android.intent.action.NEW_OUTGOING_CALL" /> </intent-filter> </receiver> The problem is that when I try it on a new system, it doesn't work at first , But after a few

How to retain progress bar state while switching the fragments?

戏子无情 提交于 2019-12-24 11:27:33
问题 I have a navigation drawer where these many options are present Image material Video Material Audio Material We are maintaining separate fragment for each material and every fragment have grid view in which we are populating thumbnail of that material. Once user click on the thumbnail a full material will be downloaded(Using AsyncTask). I am displaying the progress bar over the thumbnail while downloading the full material. Now here i stuck to a problem that suppose progress bar is showing 20

BroadcastReceiver for SCREEN_ON and SCREEN_OFF even after quitting the app

≡放荡痞女 提交于 2019-12-24 10:58:53
问题 I'm trying to make an app that monitors the users phone usage by tracking time of screen lock and unlock. I tried to setup a BroadcastReceiver which works fine when the app is running the background. But won't work when I close the app. Is there a solution for this. The code I'm using now is as follows : public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main)

SMS Logger: method getContentResolver() is undefined for the type

左心房为你撑大大i 提交于 2019-12-24 10:58:28
问题 I'am begginer in android programming and I'am trying to create app that is logging sms's to a file. Iam having a problem with "The method getContentResolver() is undefined for the type SMSObserver" and i dont know why... Here is the code: public class SMSObserver extends ContentObserver { SMSLogger smsLogger; public SMSObserver(SMSLogger smsLogger) { super(new Handler()); this.smsLogger = smsLogger; } @Override public void onChange(boolean selfChange) { super.onChange(selfChange); querySMS();

How to keep service alive when remove app from stack

丶灬走出姿态 提交于 2019-12-24 10:58:05
问题 I want to show notification every minute using Alarm Manager, I have implemented below code, it's working fine but the problem is when I remove app from stack the service is not running. I want keep alive, I have tried START_STICKY in onStartCommand and also used onTaskRemoved but it's same. I also tried to implement using WakefulIntentService but the problem is same. My code is below. In MainActivity Intent myIntent = new Intent(NotificationDemo.this, MyReceiver.class); myIntent.putExtra(

Android Broadcastreceiver for other apps install/delete not working

无人久伴 提交于 2019-12-24 10:09:11
问题 I have a Broadcastreceiver to detect other apps installs or deletion. This is my Java public class AppListener extends BroadcastReceiver { @Override public void onReceive(Context var1, Intent var2) { // TODO Auto-generated method stub Log.d("AppTag", "Received!"); } } This is my manifest <receiver android:name=".AppListener"> <intent-filter android:priority="999"> <category android:name="android.intent.category.DEFAULT" /> <action android:name="android.intent.action.PACKAGE_ADDED" /> <action

Listening for SMS and automatically replying to it in Android

你。 提交于 2019-12-24 09:57:39
问题 How to reply to an incoming message automatically in android? Here's my onReceive() method from my IncomingSMS class which extends BroadcastRecevier, problem with it is that it sends many messages, I want it to send only one SMS reply. public class IncomingSMS extends BroadcastReceiver{ private String senderNumber; @Override public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras(); SmsMessage[] msgs = null; String message = ""; if(bundle != null){ Object[]

Android - Broadcast Receiver works on Emulator Not on Phone

浪子不回头ぞ 提交于 2019-12-24 09:55:58
问题 I have written a simple app which atm just pops up a toast message when the network state changes. This works perfectly on the emulator but I've tried it on 2 different android phones and it seems like the broadcast reciever is never trigger on these events. This is my broadcast reciever: public class PhoneStateReceiver extends BroadcastReceiver { @Override public void onReceive( Context context, Intent intent ) { Toast.makeText( context, "Hi", Toast.LENGTH_SHORT ).show(); } } This is my

I can't get a startService working from my BroadcastReceiver

守給你的承諾、 提交于 2019-12-24 09:32:52
问题 I am trying to start my Service when an alarm gets triggered from my BroadcastReceiver. I am not getting any error and the code runs, but its not starting my service and I am not getting any errors. Could it be a problem that is in my Service or in the manifest? I have noticed that I am often getting problems when it comes to Intents and Contexts. I have tried to read up on it, but I can't find a site that explains it in a good way though. Any suggestions? public class Alarm extends

How to update UI from BroadcastReceiver after screenshot

丶灬走出姿态 提交于 2019-12-24 07:58:46
问题 Main problem: I need to update the UI after a screenshot occurs. I tried programmatically creating a BroadcastReceiver in onResume() in MainActivity.java and it is not picking up screenshots for some reason. So, I tried a BroadcastReceiver declared in the Manifest and it picks up screenshots correctly, but I cannot update the UI. BroadcastReceiver defined in AndroidManifest.xml as inner class of Activity must be static or I get this error: java.lang.RuntimeException: Unable to instantiate