android-broadcast

Abort SMS Intent on Android KitKat

半世苍凉 提交于 2019-11-27 23:54:32
问题 I'm currently developing an application that needs to deal with SMS only if it is an SMS expected by the application (same behaviour as Whatsapp on registration). I would like to abort the SMS Intent as it is not expected to appear in the SMS box. My question is : I know that Google changed a lot about SMS behaviour in KitKat, and now, even if my SMS is well parsed by my application, the SMS also appear in SMSBox, even if I call this.abortBroadcast(); in my SMS broadcast receiver. So is there

Android - Trying to test a service on boot (java.lang.SecurityException: Permission Denial)

风流意气都作罢 提交于 2019-11-27 22:56:06
I've been trying to test a service when a device boots up on android, but I cannot get it to work. I'm trying to start it with this command from CMD: (in ..\AppData\Local\Android\sdk\platform-tools) adb shell am broadcast -a android.intent.action.BOOT_COMPLETED or adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME -n net.fstab.checkit_android/.MyReceiver AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.tabache.sciopero"> <uses-permission android:name=

Android 8.0 Oreo AlarmManager with broadcast receiver and implicit broadcast ban

[亡魂溺海] 提交于 2019-11-27 22:18:50
I have critical reminders that are set via the Alarm Manager (It should function the same way as an alarm clock application). Previously I had the following in my Android Manifest: <receiver android:name="com.example.app.AlarmReceiver" > <intent-filter> <action android:name="${packageName}.alarm.action.trigger"/> </intent-filter> </receiver> The broadcast receiver: public class AlarmReceiver extends BroadcastReceiver { @Override public void onReceive( final Context context, final Intent intent) { // WAKE LOCK // BUILD NOTIFICATION etc... } } How the alarm is set: final PendingIntent operation

BroadcastReceiver for Screen On/Off not working

拥有回忆 提交于 2019-11-27 21:37:18
I am trying to use BroadcastReceiver but it is not working, please help me to solve this problem. MyReceiver.java package com.example.broadcast_receiver; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; public class MyReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub Log.i("[BroadcastReceiver]", "MyReceiver"); if(intent.getAction().equals(Intent.ACTION_SCREEN_ON)){ Log.i("[BroadcastReceiver]", "Screen ON"); } else if(intent

Alarm Manager does not work in background on Android 6.0

霸气de小男生 提交于 2019-11-27 20:45:31
This is my Activity code, Long time = new GregorianCalendar().getTimeInMillis()+20000;//Setting alarm after 20 sec Intent intentAlarm = new Intent("alarm"); intentAlarm.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intentAlarm.putExtra("req_code",10); PendingIntent pendingIntent = PendingIntent.getBroadcast(context,10, intentAlarm, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, time, pendingIntent); These are all the permissions that I have in my app, <uses-permission android:name=

Repeating Alarm Manager After reboot

放肆的年华 提交于 2019-11-27 16:18:23
i want to create broadcast AlarmManager(repeating) with Notification message.i pass my calender object from Pickers. If i don't reboot my device it works normally. However, when i reboot my device,as you know my calander object will be null. How can i manage my repeating alarm after rebooting and how can i hold my Calendar schedules? Thanks for your ideas. public class MyReceiver extends BroadcastReceiver { private static final int PERIOD = 10000; final public static String ALARM_ID = "AlarmId"; final public static String NOTIFICATION_ID = "NotificationId"; @Override public void onReceive

How to trigger MediaScan on Nexus 7?

我们两清 提交于 2019-11-27 14:31:10
Because I want to make sure the MediaStore has the latest information without having to reboot I'd like to trigger the MediaScanner using the popular way I found on SO context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); This works fine on my Samsung S2 w/ICS but not on my Nexus 7 w/JellyBean. Logcat shows this on my Nexus 7: WARN/ActivityManager(480): Permission denied: checkComponentPermission() owningUid=10014 WARN/BroadcastQueue(480): Permission Denial: broadcasting Intent { act=android.intent.action.MEDIA_MOUNTED

Differentiate implicit broadcast receiver vs explicit broadcast receiver in the manifest

房东的猫 提交于 2019-11-27 13:53:32
问题 According to the migration guide to Android O given by Google, most of the implicit broadcast intent should not be registered in the Manifest (minus a few exceptions found here) but explicit broadcast intents remain untouched. We are looking to move any needed broadcast away from the manifest. But how do we recognise if a receiver is implicit? Is there a general rule? Here is a sample of the broadcasts we register in the manifest. Should we look only at the "action" tag and see if it is

Detect Lock Screen Incorrect Password by user in Android

会有一股神秘感。 提交于 2019-11-27 13:20:05
问题 I am building a security app and I need to know if the user is giving incorrect password . Suppose user phone is locked by pattern lock system , and unfortunately user has forgotten the pattern password.When user give wrong pattern 5 time, there will be a penalty for 30 sec . I need to catch that penalty event . In my app, i have to do some task (for the safety of user) when this even come . Please help me, 回答1: You can set up a DeviceAdminReceiver that will be notified about failed password

Using LocalBroadcastManager to communicate from Fragment to Activity

杀马特。学长 韩版系。学妹 提交于 2019-11-27 09:23:33
EDIT: This question was created as part of one of my first Android projects when I was just starting out with Android application development. I'm keeping this for historical reasons, but you should consider using EventBus or RxJava instead. This is a gigantic mess. Please DO NOT CONSIDER using this. Thank you. In fact, if you want something cool that solves the problem of using a single activity with multiple "fragments", then use flowless with custom viewgroups. I have implemented a way to initiate the creation of Fragments, from Fragments using a broadcast intent through the