broadcastreceiver

NotificationManager.cancel(id) is not working inside a broadcast receiver

别说谁变了你拦得住时间么 提交于 2019-11-29 02:02:14
Android: I am trying to cancel a notification from the notification bar after a package being installed. What I am doing is the following: public class MyBroadcastReceiver extends BroadcastReceiver { private static final String TAG = "MyBroadcastReceiver"; @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (Intent.ACTION_PACKAGE_ADDED.equals(action)) { Uri data = intent.getData(); //some code goes here //get the id of the notification to cancel in some way notificationhelper._completeNotificationManager.cancel(id); } } } where public class

Starting Service from BroadcastReceiver

谁都会走 提交于 2019-11-29 02:01:39
问题 I have a Service and BroadcastReceiver in my application, but how do I launch the service directly from the BroadcastReceiver ? Using startService(new Intent(this, MyService.class)); does not work in a BroadcastReceiver , any ideas? EDIT: context.startService(..); works, I forgot the context part 回答1: Don't forget context.startService(..); 回答2: should be like that: Intent i = new Intent(context, YourServiceName.class); context.startService(i); be sure to add the service to manifest.xml 回答3:

Android broadcast receiver not working

和自甴很熟 提交于 2019-11-29 01:52:53
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 android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <

Restricting Android Broadcast Receiver from specific app

北城以北 提交于 2019-11-29 00:14:59
I have 2 applications. If I use service, I can set permission so only app1 can send intent to app2 : Define permission in app2 ( protection level: signature ), and use that permission in app1 . Service in app2 is protected by that permission. In this way, only app1 can send an intent to a service on app2 , and no other app (unless my signature is leaked) can send intent to service on app2 . Can I do the same with Broadcast Receiver? app1: sendBroadcast(intent, permission) app2: define permission, use that permission. To my understanding for using sendBroadcast(intent, permission), the

How to modify incoming and outgoing call screen view in android

此生再无相见时 提交于 2019-11-28 23:58:00
问题 I want modify below screen according to my option. I don't know how to access this screen. and i need to modify this screen also Please help me to do this. 回答1: You cannot modify default screen but instead of this you can launch your screen for that you need to use BroadCastReceiver for incoming calls here is the link for getting phone state in broadcast receiver http://www.tutorialforandroid.com/2009/01/get-phone-state-when-someone-is-calling_22.html 回答2: You have to write a broad cast

How can one detect an Android application launching?

情到浓时终转凉″ 提交于 2019-11-28 23:29:04
Is it possible to detect when an app is executed (i.e., when the user clicks on the app's icon)? I attempted to register an intent of type Intent.ACTION_MAIN using a category of of type Intent.CATEGORY_LAUNCHER hoping this would let me know whenever an app is launched. The problem is, my broadcast receiver is never getting called. Is this an illegal intent/category combination for which to register? Is there some method I can use to determine when an application launch occurs? Femi The application start Intent is not a broadcast, so there is no way to register a broadcast receiver and receive

GCM with custom broadcastreceiver

本小妞迷上赌 提交于 2019-11-28 23:26:40
问题 I am implementing gcm notifications in my application. Because I use my code to generate lot of application with different package names I cannot use standard mypackage.GCMIntentService name. When generating applications I do changes only in Manifest and change imports of my R class. So I impelented my own BroadcastReceiver public class GCMReceiver extends GCMBroadcastReceiver { @Override protected String getGCMIntentServiceClassName(Context context) { return GCMIntentService.class.getName();

Android BroadcastReceiver onReceive() called twice on android 4.0

血红的双手。 提交于 2019-11-28 22:50:52
I faced to one problem on android 4.0.3 (on 4.1.2 it works fine). I have in my Activity BroadcastReceiver. When I send a broadcast, method onReceive() called always twice. Please give me any suggestions about BroadcastReceiver differences on 4.0 and 4.1 private final GcmBroadcastReceiver gcmReceiver = new GcmBroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (action != null && action.equals(MyBroadcastReceiver.ACTION)) { Log.d("tag", intent.getStringExtra("alert")); } } }; }; @Override protected void onPause() {

Android MediaProjectionManager in Service

孤者浪人 提交于 2019-11-28 21:56:53
I want to build an app where I have to use MediaProjectionManager in a Service. But I can not solve it as 'startActivityForResult' can't use in Service class. I really want to do this from a service, which is how I found this question. This is the closest I've came up, so just throwing this out there, till a better answer comes along. Here's a way to do it from an activity that's almost like doing it from a service: import static your.package.YourClass.mediaProjectionManager; public class MainActivity extends Activity { @Override protected void onCreate(final Bundle savedInstanceState) { super

how to run application in background in android?

一曲冷凌霜 提交于 2019-11-28 21:40:02
Hi, I want to make an Android application that continues to run in background and when user accesses any folder, picture, or any other file it notifies using toasts that he accesses this file(filename). The other people answering your question are focused on the "background" part, and a Service would indeed accomplish this. Users have fairly loudly stated that they despise constantly-running services like the one you are proposing. when user access any folder or picture or any file it notify using tosts that he acess this file(filename). For files that you can access yourself (e.g., those on