broadcastreceiver

How to include a bundle extra when testing Android broadcasts?

对着背影说爱祢 提交于 2019-12-10 06:56:03
问题 I'm currently trying to test Google's App Invites, but I'm having a tough time testing the INSTALL_REFERRER broadcast feature without putting an app up on the Play Store App Invite broadcast intents require a bundle extra named "com.google.android.gms.appinvite.REFERRAL_BUNDLE" and it's checked in AppInviteReferral like so: public static boolean hasReferral(Intent referralIntent) { return referralIntent != null && referralIntent.getBundleExtra("com.google.android.gms.appinvite.REFERRAL_BUNDLE

BroadcastReceiver how to start new intent

自作多情 提交于 2019-12-10 06:08:51
问题 I implemented a broadcast receiver to "block" my app if the internet connection is lost. By block I mean that the app has to open a "No internet connection" activity. this is my receiver code: public class ConnectivityReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { boolean noConnectivity = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false); Log.d("** Debug **","noConnectivity " + noConnectivity); if(noConnectivity){

C2DMBroadcastReceiver's onReceive is not executing (For Registration)

故事扮演 提交于 2019-12-10 04:44:35
问题 Im developing a C2DM Messaging application. In that i order to receive the registration id im using the C2DMBroadcastReceiver , C2DMBaseReceiver and C2DMMessaging class. I will be C2DMReceiver in my package which extends the C2DMBaseReceiver . Here is my code snippet C2DMMessaging.java package com.google.android.c2dm; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content

Google Awareness Api events while app isn't running

a 夏天 提交于 2019-12-10 04:34:05
问题 I would like either a BroadcastReceiver or IntentService (depending on how long my eventual processing takes) to start when a Google Awareness API "fence" fires. For example, perhaps I want to know how many times I activate a set of beacon fences over the course of the day (assuming I keep my phone with me). All the examples I've found show registering broadcast receivers in code, but my understanding is that I would need to register a broadcast receiver in the manifest in order for the OS to

Can't receive broadcast Intent of UsbManager.ACTION_USB_DEVICE_ATTACHED/UsbManager.ACTION_USB_DEVICE_DETACHED

萝らか妹 提交于 2019-12-10 03:36:39
问题 I am coding an USB host App recently, but it's stucked because I can't detect the device attached/detached event, I followed the coding note of http://developer.android.com/guide/topics/connectivity/usb/host.html and refer to other's coding in the network, After checking several times, I still can't find the problem. After my debugging, it seems that the UsbManager.ACTION_USB_DEVICE_ATTACHED/UsbManager.ACTION_USB_DEVICE_DETACHED intent is not happened, Because I try to use Context

Bring an activity to front in android Broadcast Reciever

青春壹個敷衍的年華 提交于 2019-12-10 00:05:05
问题 I'm trying to launch an activity , when i got an incoming call for my android mobile. For that, in ringing state, i started an activity and sets some flags for bring this activity to front. Here is the Code: Intent intent2open = new Intent(ctx, Main.class); intent2open.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); intent2open.setAction("android.intent.action.VIEW"); intent2open.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

Android Lock Screen and Keyboard Controls

亡梦爱人 提交于 2019-12-09 23:37:31
问题 I am part way through writing a media player app for Android. It's all going really well so far, however I am now reaching the difficult stage! I have two questions. Do i need to implement a service activity? As I understand it, this is required to allow the app to continue working in the background. However, mine is working fine while I move to other programs on the tablet, and returns to the app without problems. Can someone please explain what the advantages are of services? Secondly, I

How I can receive hardware key events in sleep mode?

谁说我不能喝 提交于 2019-12-09 19:08:21
问题 I'm writing an application that allows people in danger to call 911. This is how it should work: He (or she) feels danger. He pushes the volume-down key three times. My app calls 911. But I'm facing the following problem: how can I receive a hardward key event in sleep mode ? I've searched Google and other search engines, but can't find anything related. 回答1: public class YourBoardcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if

How can I send an SMS from a BroadcastReceiver and check its status?

拥有回忆 提交于 2019-12-09 18:21:39
问题 So this is my BroadcastReceiver public class IncomingSMSListener extends BroadcastReceiver { private static final String SMS_EXTRA_NAME = "pdus"; @Override public void onReceive(Context context, Intent intent) { SmsMessage[] messages = fetchSMSMessagesFromIntent(intent); } private SmsMessage[] fetchSMSMessagesFromIntent(Intent intent) { ArrayList<SmsMessage> receivedMessages = new ArrayList<SmsMessage>(); Object[] messages = (Object[]) intent.getExtras().get(SMS_EXTRA_NAME); for (Object

Android开机自动运行APP——BroadcastReceiver

徘徊边缘 提交于 2019-12-09 17:12:20
前言: 有些时候,应用需要在开机时就自动运行,例如某个自动从网上更新内容的后台service。怎样实现开机自动运行的应用?在撰写本文时,联想到高焕堂先生以“Don't call me, I'll call you back!”总结Android框架,真是说到点子上了。理解这句话的含义,许多有关Android平台上实现某种功能的问题,都能迎刃而解。 使用场景: 手机开机后,自动运行程序。 {只是最近本人在做万达大歌星点餐系统,需要用到系统启动直接启动App避免服务员玩别的app才研究的,以下分享是本人参考网络,亲自尝试成功的代码,贴出来与大家分享,希望能帮助更多的人!不懂的可以问我哦。QQ:11745405 } 背景知识: 当Android启动时,会发出一个系统广播,内容为ACTION_BOOT_COMPLETED,它的字符串常量表示为android.intent.action.BOOT_COMPLETED。只要在程序中“捕捉”到这个消息,再启动之即可。记住,Android框架说:Don't call me, I'll call you back。我们要做的是等到接收这个消息,而实现的手段就是实现一个BroadcastReceiver。 代码解析: 1、界面 MainActivity .java package com.example; import android.app