android-broadcast

Broadcast Receiver class and registerReceiver method

喜欢而已 提交于 2019-11-27 07:53:56
Hi i am trying to understand Broadcast Receiver , i went through many sample codes , but still have some doubts. I wanted to know when we have to extend the Broadcast Receiver class and when should we use registerReceiver() method and when should we create object for BroadcastReceiver. In some programs i came across registerReceiver methods being used but without extending the Broadcast Receiver class. I also wanted to know how the onReceive method gets called. Which approach should be used when? here is the registerReceiver method: registerReceiver(new BroadcastReceiver() { @Override public

Music player control in notification

喜你入骨 提交于 2019-11-27 06:25:32
how to set notification with play/pause, next and previous button in android.! I am new with Android & also at stack overflow. So please bear with me. I set notification when song is start to play like below : ` @SuppressLint("NewApi") public void setNotification(String songName){ String ns = Context.NOTIFICATION_SERVICE; NotificationManager notificationManager = (NotificationManager) getSystemService(ns); @SuppressWarnings("deprecation") Notification notification = new Notification(R.drawable.god_img, null, System.currentTimeMillis()); RemoteViews notificationView = new RemoteViews

BroadcastReceiver for Screen On/Off not working

╄→尐↘猪︶ㄣ 提交于 2019-11-27 04:31:49
问题 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

java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.MEDIA_MOUNTED on KitKat only

孤街醉人 提交于 2019-11-27 04:06:40
I am using the DownloadManager to download images off our server and I am placing the files in the externalFilesDir . I am send out a broadcast intent because I don't want these downloaded images to appear in the gallery. sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + context.getExternalFilesDir(null)))); I only tested this on my Galaxy S3 Jelly Bean 4.3 prior and it was working, but when I tested it on KitKat 4.4 it crashes the app. Is there a better way to not have the files downloaded from the DownloadManager not appear in the phone gallery? Stack Trace 06-05 17

Fatal Exception: android.app.RemoteServiceException: can't deliver broadcast at android.os.Handler.dispatchMessage

微笑、不失礼 提交于 2019-11-27 03:55:47
问题 I am using broadcast messages on my android application (From io.socket I am sending broadcast messages to my Activity page). On some devices Samsung SM-G950F and SM-A520F I got an error " Fatal Exception: android.app.RemoteServiceException: can't deliver broadcast ". I got this error on Fabric crashlytics also I was not able to reproduce this issue. Here is the log I got from Fabric, Fatal Exception: android.app.RemoteServiceException: can't deliver broadcast at android.app.ActivityThread$H

Should I use android: process =“:remote” in my receiver?

懵懂的女人 提交于 2019-11-27 02:49:36
I have a BroadcastReceiver which is called every so often, and I have noticed many people use android: process =":remote" in their receiver. Mine is used to check a few things and if the conditions match then activate an alarm. My question is should I use the line I had posted above in my manifest? And if so what are the benefits of doing so? ddewaele By defining your receiver with android:process=":remote" you basically run your receiver in a different process (= VM). For typical use-cases, you don't need to run this in a different process, and whatever you want to do can probably run just

Broadcast Receiver Not Working After Device Reboot in Android

早过忘川 提交于 2019-11-27 02:42:48
I have already checked all the related questions and have not found any solution for this problem. So this is an absolutely new problem for me. What I Have I have an Android app which registers a few broadcast receivers in its manifest. This is what my manifest looks like. <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.app.myapp"> <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" /> <uses-permission android:name="android.permission.RECEIVE_BOOT

what is the difference between sendStickyBroadcast and sendBroadcast in Android

两盒软妹~` 提交于 2019-11-27 02:31:24
What is the difference between sendStickyBroadcast and sendBroadcast in Android? Here is what the Android SDK says about sendStickyBroadcast() : Perform a sendBroadcast(Intent) that is "sticky," meaning the Intent you are sending stays around after the broadcast is complete, so that others can quickly retrieve that data through the return value of registerReceiver(BroadcastReceiver, IntentFilter). In all other ways, this behaves the same as sendBroadcast(Intent). One example of a sticky broadcast sent via the operating system is ACTION_BATTERY_CHANGED . When you call registerReceiver() for

Alarm Manager does not work in background on Android 6.0

给你一囗甜甜゛ 提交于 2019-11-26 22:58:27
问题 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,

Broadcast Receiver class and registerReceiver method

旧巷老猫 提交于 2019-11-26 22:17:03
问题 Hi i am trying to understand Broadcast Receiver , i went through many sample codes , but still have some doubts. I wanted to know when we have to extend the Broadcast Receiver class and when should we use registerReceiver() method and when should we create object for BroadcastReceiver. In some programs i came across registerReceiver methods being used but without extending the Broadcast Receiver class. I also wanted to know how the onReceive method gets called. Which approach should be used