Android :: Broadcast Receiver / Service Will Only Restart Activity Once

Mar 17, 2010

I have a single Activity application, within it I have a service which creates an AlarmManager and sends a broadcast to a broadcast Receiver.If the activity which starts the services dies, (ie. divide by zero), the broadcast receiver stops the old service which created the AlarmManager.It works the first time. The second time, it does not.It seems like the AlarmManager is still active but the broadcast receiver is no longer receiving. It works great once!

Android :: Broadcast Receiver / Service will only restart activity once


Android :: Broadcast Receiver - Create A Broadcast Receiver Which Responds To System Events

Sep 28, 2009

trying to create a broadcast receiver which responds to system events and change system settings. I don't need any interaction from the user so I don't need an activity and have been trying to do everything through the manifest file. I've put a log event into my onReceive method but it never logs anything so I'm presuming my method is never called. I've tried this with both the 1.5 and 1.6 SDKs. I was hoping somebody could have a look at my code please and let me know if there are any problems.

View 2 Replies View Related

Android :: How To Use Intents From Service Or Broadcast Receiver?

Dec 15, 2009

I need to be able to handle/catch Intents while my Activity is closed. So I am looking at either a Service or a BroadcastReceiver. Is it possible to "receive" intents to a service itself? I tried to search, but could not find anything helpful. With a BroadcastReceiver, I am not exactly sure how that works outside of an Activity. Does it depend on the Activity being open/running? Can it run by itself?

Let's say that my Activity is killed by Android(or a task killer app), does the BroadcastReceiver still receive intents and process them? I have used a BroadcastReceiver as a widget, but I do not want to use a widget this time. My goal is to have the user open the Activity to set some options. From there, they would be able to close the Activity, but I would still be able to process Intents that were sent out by the system. I am still fairly new to Android development, so I could be so far away from where I need to be.

View 1 Replies View Related

Android :: Broadcast Receiver / Service & Thread

Jun 23, 2010

I am starting to develop a new app and I am a bit confused about the structure I need to give it.I need to react to broadcast intents, so I placed a broadcast received in the manifest. Every single intent produces an action to be performed. Now the first question: should I start a service (maybe with non_sticky option?) or should I start a thread (or an async task) directly from the broadcast receiver? If I start a service, should I do all the stuff in its body, or should it start a thread. I should do the heavy job in a thread if there are time consuming operations, but what if the gui of my application is just an activity with the options and a button to start the service. What is the point in keeping the main thread busy? Do I risk to be killed for not being responsive? I read here and there that I can update the gui from a background thread. Can I do that even if it is started from a service? The AsyncTask's onProgressUpdate is said to run in the application main thread, but if the application is made of different activities, who tells me which activity is the user looking at while the thread is doing all its long work? The user could change activity in the meanwhile and then the update would be unuseful.I know it's (quite) a lot of questions, but I need to get some clarifications before taking the wrong path.

View 5 Replies View Related

Android :: Broadcast Receiver And Remote Service

Jan 20, 2010

I'm hoping to do some audio processing in a remote service (service I've spawned onto its own thread); this will basically occur in a while (1) loop so constant processing. Occasionally I want to provide some information back to the activity that is bound to the service; I'm doing this by sending a broadcast from the service, that is received by a broadcast receiver on the activity, which then uses the activity's service connection to call into the service and get the information needed; at this point the broadcast receiver makes an alert dialog presenting the information to the user.If I stay in my while(1) loop after raising the broadcast, the action in the broadcast receiver never seems to occur.This is confusing to me since the activity and service are in separate threads.If I end the loop after raising the broadcast, the desired behavior on the activity side occurs, but of course this isn't acceptable since I need to be doing constant processing.

View 11 Replies View Related

Android :: How To Communicate Back To Service From Broadcast Receiver?

Aug 17, 2010

I have a widget which starts a service. The service registers two broadcast receivers. I would like to send back intents from the receivers to the service, so that the service can react.I remember reading (on some blog) that this won't start a new service, but will simply pass the intent to the already running service. Is this correct? Is it a bad way of doing it? Is there a better way?

View 1 Replies View Related

Android :: Broadcast Receiver Without Activity

Feb 12, 2010

A WAP PUSH (Broadcast)receiver basically doesn't need any UI. It is a silence application which handles the Push messages based on actions/ mimetype without needing any intreaction with user, I've tried to test it in a SMS receiver by removing the Activity from the project and it stopped receiving the SMS messages. My question: Does all android applications "MUST" define a activity? Is there a way to hide it?

View 5 Replies View Related

Android :: Starting An Activity From Broadcast Receiver

May 28, 2010

I am trying to launch the Main Activity from a broadcast receiver. Can anyone guide me as to how I can do it? I always get "Process is Bad" message.

View 1 Replies View Related

Android :: How To Call Broadcast Receiver From Activity?

Jul 9, 2010

I have a broadcast class that blocks the incoming call. I want to call that broadcast receiver from the activity ? Can any one help me fix this. I appreciate your help. 1. Class A extends activity will call Class B that extends BroadcastReceiver, now I want to block calls , only based on certain requirements, which are checked in Class A, if true then call the Class B (or block the call in short)

View 3 Replies View Related

Android :: Keep Broadcast Receiver Process Alive / By Creating Service That Stays Around?

Sep 16, 2009

The app widget documentation indicates that the "widget provider"being a receiver of a broadcast service may not exist (the process) beyond the completion of the call.If I want to maintain state between two broadcast events, such as say widgetProvider.onUpdate(), can I start a local service and leave it hanging there until my widgets are disabled? If I didn't explicitly stop that service will it be loaded again and resumed when the device wakes up.

View 4 Replies View Related

Android :: Starting Translucent Activity From Broadcast Receiver

Sep 30, 2010

I got a graphical problem regarding the Translucent theme at Samsung Galaxy i9000.It works well in the emulator with android version ranging from 1.6 to 2.2 as well as on SE x10 mini.I have yet to test on more devices.I am starting an activity from a broadcast receiver. The activity started got the theme @android:style/Theme.Translucent If all the activities in my application are destroyed when the broadcast occurs, then the new activity got a working translucent theme and is presented on top of the activity currently in front. However, if the user left the application with the HOME-key, not destroying the activity, I get a graphical bug when the broadcast triggers. The application gets brought to the front with the activity the user last visited showing instead of the new activity that I started from my broadcast receiver. When I press the back key I can see my Translucent activity quickly showing itself and then getting destroyed.This flow results in the graphical bug: Start application. Activity A will be shown. Leave application by pressing HOME-key. Home screen is shown. Trigger broadcast. Start activity B.

Application gets brought to foreground and activity A is shown. Press BACK-key. Activity B quickly shows itself and disappears. Now activity A is shown.Also, after activity B is started and when activity A is shown in its place. Pressing the screen will triggers buttons that belong in activity B even if the user can't see them. If I remove the theme, then activity B will show itself when it's supposed to.Is there anyone else who have encountered a similar problem? Is there any good workarounds I can apply? (I don't want to rebind home to finish all activities) Is the problem my fault or can there possibly be some glitch in Touchwiz?

View 2 Replies View Related

Android :: Update Activity / Layout From Within Broadcast Receiver

Jun 29, 2010

I have a layout with two buttons, I want to disable or make unclikable one of the buttons when internet connection is lost and back to clickable when connection is regained. From my broadcast receiver I am calling another class(which extends activity and thus can call findViewById) which is attempting to change the main layout. App is force closing. What am I doing wrong here, any other ideas as to how to achieve what I am trying to do.

View 4 Replies View Related

Android :: Notify Running Activity From Broadcast Receiver?

Jun 26, 2010

I have an activity, it needs to response to a broadcast event.Since an activity can not be a broadcast receiver at the same time,I made a broadcast receiver.My question is: how can I notify the activity from the broadcast receiver?I believe this is a common situation, so is there a design pattern for this?

View 1 Replies View Related

Android :: How To Send Data From Broadcast Receiver To Activity?

Mar 25, 2010

I am writing an application to listen the SMS inbox in android with one activity and one BroadcastReceiver. Once the SMS comes the Receiver is showing alert message. But I want to send the message information from Receiver to Activity. I don't know how to achieve this.

View 2 Replies View Related

Android :: Broadcast Receiver Can't Receive UMS_CONNECTED - UMS_DISCONNECTED Msg Dynamically In Activity?

Nov 20, 2009

I was make source to catch and process SD Card mount/unmount broadcast received dynamically in activity.

but the USM_CONNECTED/DISCONNECTED broadcast msg is not catched dynamically in activity like below:.

how the receiver can receive the UMS msg in activity?

below:

CODE:......................

View 3 Replies View Related

Android :: Need To Implement "broadcast Receiver" Functionality In My Service?

Nov 18, 2010

I have to handle "power down" event in my service, but so far I couldn't find how to receive "power down" event...Do I need to implement "broadcast receiver" functionality in my service? I would appreciate some pointers.

View 2 Replies View Related

Android :: Android - SMS Broadcast Receiver / No Launcher Activity Found

Nov 7, 2010

I have been trying to get this program to work but so far having no luck. I cannot find where I am doing wrong. I'm not sure if there's something wrong with the code, or debugging.

Here is my program:
package Technicaljar.SMSBroadcastReceiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.util.Log;

public class SMSBroadcastReceiver extends BroadcastReceiver {
private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
private static final String TAG = "SMSBroadcastReceiver";
@Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "Intent received: " + intent.getAction());
if (intent.getAction() == SMS_RECEIVED) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdus = (Object[])bundle.get("pdus");
final SmsMessage[] messages = new SmsMessage[pdus.length];
for (int i = 0; i < pdus.length; i++) {
messages[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
} if (messages.length > -1) {
Log.i(TAG, "Message recieved: " + messages[0].getMessageBody());
} } } } }

And the manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="Technicaljar.SMSBroadcastReceiver"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true" >
<receiver android:name=".SMSBroadcastReceiver">
<intent-filter>
<action android:name="android.provider.telephony.SMS_RECEIVED"></action>
</intent-filter>
</receiver>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET">
</uses-permission>
<uses-permission android:name="android.permission.RECEIVE_SMS">
</uses-permission>
</manifest>

I am sending SMS through Telnet, and I cannot see any Intent received messages in the logcat. Here is my logcat from the time of installation.

D/AndroidRuntime( 478):
D/AndroidRuntime( 478): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/AndroidRuntime( 478): CheckJNI is ON
D/AndroidRuntime( 478): --- registering native functions ---
D/AndroidRuntime( 478): Shutting down VM
D/dalvikvm( 478): Debugger has detached; object registry had 1 entries
I/AndroidRuntime( 478): NOTE: attach of thread 'Binder Thread #3' failed
D/Mms:app ( 220): getSmsNewMessageNotificationInfo: count=14, first addr=12345, thread_id=4
D/dalvikvm( 151): GC_EXPLICIT freed 391 objects / 22552 bytes in 65ms
D/dalvikvm( 220): GC_EXPLICIT freed 926 objects / 44840 bytes in 73ms

So the SMS seems to be received by the emulator, but looks like the no intents are firing.
What am I doing wrong here? After installing, do I have to somehow 'start' this receiver?
Because when I install, I get

[2010-11-07 21:24:41 - SMSBroadcastReceiver] No Launcher activity found!
[2010-11-07 21:24:41 - SMSBroadcastReceiver] The launch will only sync the application package on the device!

View 1 Replies View Related

Android :: Starting Activity From Service / Receiver?

Oct 27, 2009

I have a service that sometimes starts applications.The problem is: if the *previous app* (any app) was recently exited via the home key, then the following message appears in the log:ActivityManager: Activity start request from 10024 stopped.And there's then around a 5 second delay before the target app (any) is launched.If the previous app was exited with the back key, there's no problem.If the previous app exited more than a few second ago, no problem.The same also occurs with a broadcast receiver (which also requires the NEW_TASK intent flag to launch an activity).I don't know if the delay was there in 1.5, but I'm assuming not since I can't find the error message in the 1.5 source code.

View 5 Replies View Related

Android :: Start TTS From Broadcast Receiver

Jul 9, 2009

I am trying to start TTS from a broadcast receiver and it as document an intent receiver can't bind the service. Is there a work around, I can't figure out how to start the service using startService(Intent, Bundle).

View 4 Replies View Related

Android :: Broadcast Receiver Error

Jul 23, 2010

I am working on one project where i am using broadcast receiver in one of my activity to capture the incomming call and its works fine. when one of my other activity is open and that time if call is come then my broadcast receiver is fail to respond. can any one help me for this ? or its nessesorry to declare broadcast receiver in all my activity to do some comman task.

View 5 Replies View Related

Android :: Broadcast Receiver From Widget

Dec 2, 2009

I am making a widget that needs a broadcast receiver, like the one in com.example.android.apis.appwidget.ExampleBroadcastReceiver. However, the example defines Intent.ACTION_TIMEZONE_CHANGED in the manifest, but there are some that do not allow this. For example, Intent.ACTION_TIME_TICK says "You can not receive this through components declared in manifests, only by exlicitly registering for it with Context.registerReceiver(). "

So I removed the manifest declarations and tried replacing the AppWidgetProvider.onEnabled function that was in the example with a call like the following: context.registerReceiver(myReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));
(where "myReceiver" is an instance of the receiver I want.) However, when I try to run the code, I get the following error:
Unable to start receiver...android.content.ReceiverCallNotAllowedException: IntentReceiver components are not allowed to register to receive intents.
Any way to get this broadcast receiver working from a widget?

View 3 Replies View Related

Android :: Any Other Application As Broadcast Receiver?

Jul 29, 2009

I am broadcasting an Intent from an activity. Can we make another application as a receiver. So that it will get invoked when that specific intent is broadcasted.

View 2 Replies View Related

Android :: Broadcast Receiver Sometimes Works

Jan 6, 2010

I wish to listen to android.intent.action.BOOT_COMPLETED. However I am not getting the broadcast intent, if I specify com.test.BootBroadcastReceiver in the manifest. When I change this value to simply BootBroadcastReceiver, then I am getting the broadcast intent.

<receiver android:name="BootBroadcastReceiver" android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>

My package in the manifest file is:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test"
And the BootBroadcastReceiver resides in this package. What is the reason behind this?

View 2 Replies View Related

Android :: Trying To Understand Use Of Broadcast Receiver

Aug 17, 2009

I have an application that uses an extended Broadcast Receiver class inside the Activity. I have the extended Broadcast Receiver class as a member variable of the Activity class. But it looks like the receiver references keep changing between its construction and 'on Receive' method call. I would like to understand this better. Here are some details. public class MyEventReceiver extends Broadcast Receiver

View 3 Replies View Related

Android :: Broadcast Receiver For Action

Oct 3, 2009

I was wondering if its possible to have a broadcast receiver to listen when the app its in launches.I tried doing by creating a BroadcastReceiver to listen for the android.intent.action.MAIN action but it never gets called?Is there something I need to do or a different action I should be listening for?

View 3 Replies View Related

Android :: How To Use Broadcast Receiver In Different Applications?

May 1, 2010

I have here two applications in two different projects in eclipse. One application

(A) defines an activity

(A1) which is started first. Then i start from this activity the second activity

(B1) in the second project

(B). This works fine.

Unfortunately, the message is never received. Although the method in activity A1 is called, i never receive an intent in B1.

View 1 Replies View Related

Android :: Broadcast Receiver For Sent SMS Messages?

Jun 13, 2009

I created a BroadcastReceiver and configured it with an android.provider.Telephony.SMS_RECEIVED action filter so it is called everytime the phone receives a text.Is there some event/action or other way for my application to be notified whenever the phone sends a text (preferably independent of the application that sends it)?So far the only option I see is to poll the content provider for content://sms/sent which doesn't even give me all sent texts because applications can choose not to put it there.

View 1 Replies View Related

Android :: Set Priority To Broadcast Receiver

Oct 24, 2010

The symptom: I have a broadcast receiver that listen to sms, when a sms is received, i call an activity to display. It works all fine if the screen is on and not locked. But when screen is locked, and as soon as i received the sms, the activity popup for a second then disappeared and I use the code to unlock the screen.

getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);

I think it might be the competitions with phone default sms program (the sms default program shows a notification only). I am wondering is there a way to set priority to broadcast receivers or even the activity that receiver stared, to avoid the conflicts between multiple receivers. or set orders to execute one by one? I have tried to thread.sleep my receiver for a second, still not working.

View 2 Replies View Related

Android :: Error In Receiving SMS Using Broadcast Receiver

Oct 11, 2010

I'm trying to receive SMS using broadcast receiver. MySMSReceiver :

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.util.Log;

public class MySmsReceiver extends BroadcastReceiver {
/** Tag string for our debug logs */
private static final String TAG = "MySmsReceiver";
@Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "Recieved a message");
Bundle extras = intent.getExtras();
if (extras == null)
return;
Object[] pdus = (Object[]) extras.get("pdus");
for (int i = 0; i < pdus.length; i++) {
SmsMessage message = SmsMessage.createFromPdu((byte[]) pdus[i]);
String fromAddress = message.getOriginatingAddress();
String fromDisplayName = fromAddress;

Log.i(TAG, fromAddress);
Log.i(TAG, fromDisplayName);
Log.i(TAG, message.getMessageBody().toString());
break; } } }

and added in Mainfest file
<receiver android:name=".MySmsReceiver" android:enabled="false">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.RECEIVE_SMS" />

But when I run this application and send a SMS using emulator it shows following logs in logcat

10-12 00:14:53.082: VERBOSE/Telephony(1032): getOrCreateThreadId uri: content://mms-sms/threadID?recipient=9898989898
10-12 00:14:53.203: VERBOSE/Telephony(1032): getOrCreateThreadId cursor cnt: 1
10-12 00:14:53.432: DEBUG/Mms:app(1032): getSmsNewMessageNotificationInfo: count=4, first addr=9898989898, thread_id=3
10-12 00:14:53.482: WARN/NotificationService(62): STOP command without a player
10-12 00:14:53.562: DEBUG/MediaPlayer(62): Couldn't open file on client side, trying server side
10-12 00:14:53.582: ERROR/MediaPlayerService(34): Couldn't open fd for content://settings/system/notification_sound
10-12 00:14:53.592: ERROR/MediaPlayer(62): Unable to to create media player
10-12 00:14:53.643: WARN/NotificationService(62): error loading sound for content://settings/system/notification_sound
10-12 00:14:53.643: WARN/NotificationService(62): java.io.IOException: setDataSource failed.: status=0x80000000
10-12 00:14:53.643: WARN/NotificationService(62): at android.media.MediaPlayer.setDataSource(Native Method)
10-12 00:14:53.643: WARN/NotificationService(62): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:716)
10-12 00:14:53.643: WARN/NotificationService(62): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:671)
10-12 00:14:53.643: WARN/NotificationService(62): at com.android.server.NotificationPlayer$CreationAndCompletionThread.run(NotificationPlayer.java:8)

View 1 Replies View Related

Android :: Sometimes Receiver Not Receiving Any Broadcast Message

Sep 10, 2010

I have create a receiver which receive on phone state change I have register it in XML by "android.intent.action.PHONE_STATE"

But sometime it don't receive any broadcast message
log mesages are:::

09-10 11:20:36.968: WARN/ActivityManager(74): Timeout of broadcast BroadcastRecord{43347258 android.intent.action.PHONE_STATE - receiver=android.os.BinderProxy@4334ebd0
09-10 11:20:36.968: WARN/ActivityManager(74): Receiver during timeout: ResolveInfo{432dd748 com.callHandller.PhoneStateReciever p=0 o=0 m=0x108000}
09-10 11:20:36.968: INFO/Process(74): Sending signal. PID: 2223 SIG: 9
09-10 11:20:36.988: ERROR/JavaBinder(74): !!! FAILED BINDER TRANSACTION !!!
09-10 11:20:37.008: INFO/ActivityManager(74): Process com.callHandller (pid 2223) has died.
09-10 11:20:37.008: INFO/WindowManager(74): WIN DEATH: Window{4324f470 com.callHandller/com.incallHandller.callHandler paused=false}
09-10 11:20:37.958: WARN/ActivityManager(74): Activity destroy timeout for HistoryRecord{4321c7c0 com.callHandller/com.incallHandller.callHandler}
09-10 11:20:42.288: DEBUG/dalvikvm(136): GC freed 2543 objects / 143320 bytes in 179ms
Here com.callhandller is my application package where I have Receiver...

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved