Android : Can I Initiate Threads In BroadcastReceiver's OnReceive Method?
Dec 18, 2009
My application has two components,one is Activity and BroadcastReceiver. I am using the BroadcastReceiver as inner class of my Application. The BroadcastReceiver's onReceive method is initiating a new Thread as Thread object,every time. In that i am trying to update the activity if it is in fore ground.If it is in back ground i am simply ignoring. But some times my application is hanging as my application's "HeapWorker" thread is taking 80-90% of the CPU.
View 2 Replies
Feb 3, 2009
I am trying to get a UI to present itself when an incoming SMS happens. When that happens, I would like to present a UI to the user.
I have a BroadcastReceiver class that listens to the SMS_RECEIVED event. I also have an Activity class that is capable of displaying the needed UI when the event happens.
The questions is: How do I start the activity from within the onReceive method of BroadcastReceiver?
I know others have done this but I can't seem to find any resources that illustrates how.
View 3 Replies
View Related
Oct 13, 2010
What's the correct way (if any) to redirect a received Intent to another BroadcastReceiver? I have two BroadcastReceivers set to listen to the same intent. It works in development, but in production, only the first one registered in the manifest gets the intent. Can I call the other one's onReceive() method directly, passing the same context and intent? Is there a better way to pass the intent along once the first receiver is done with it?
View 1 Replies
View Related
Sep 7, 2010
I'm developing alarm application. I'm using listview on activity to reserve alarm. after application finish BroadcastReceiver.onReceive() method, I want to remove check of list. But i dont know how to access to activity.
View 1 Replies
View Related
Feb 19, 2010
I added a BroadCastReceiver to my application.I want to call my inputMethod's method but I can't find a way to access it's instance.but I couldn't find a way to get the the InputMethod instance from the InputMethodManager.Is doing a singleton the only way to access it?
View 1 Replies
View Related
Mar 21, 2010
I read somewhere (and have observed) that starting threads is slow. I always assumed that AsyncTask created and reused a single thread because it required being started inside the UI thread. The following (anonymized) code is called from a ListAdapter's getView method to load images asynchronously. It works well until the user moves the list quickly, and then it becomes "janky".
final File imageFile = new File(getCacheDir().getPath() + "/img/" + p.image);
image.setVisibility(View.GONE);
view.findViewById(R.id.imageLoading).setVisibility(View.VISIBLE);
(new AsyncTask<Void, Void, Bitmap>() {
@Override
protected Bitmap doInBackground(Void... params) {
try {....
View 49 Replies
View Related
Apr 13, 2010
What are the advantages/disadvantages in placing a lengthy network access code in a thread in an activity or a thread in a service? How would it affect the application? I am writing a streaming audio player and from what I've read so far putting the code in a service will still end up blocking the application so a new thread is needed, does anyone know if it makes more sense to put this piece of code in a service.
View 1 Replies
View Related
Aug 9, 2010
I initialize some arrays in an onUpdate() method and after that, using an intent and a button, I try to call onReceive() function which runs fine but cannot access arrays set in onUpdate() method. Why is that? Those array's are object variables and are declared public.Am I missing something?package net.aerosoftware.widgettest;
import java.util.HashMap;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.RemoteViews;
public class WidgetTest extends AppWidgetProvider { public static String ACTION_WIDGET_RECEIVER = "ActionReceiverWidget";
public HashMap<Integer, String> channelsImages;
@Overridepublic void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
{ Log.e("UPDATE", "Start");
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.main);
channelsImages = new HashMap<Integer, String>();
channelsImages.put(0, "one");
channelsImages.put(1, "two");
Intent active = new Intent(context, WidgetTest.class);
active.setAction(ACTION_WIDGET_RECEIVER);
PendingIntent actionPendingIntent = PendingIntent.getBroadcast(context, 0, active, 0);
remoteViews.setOnClickPendingIntent(R.id.buttonclick, actionPendingIntent);
super.onUpdate(context, appWidgetManager, appWidgetIds);
appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
Log.e("UPDATE", "End");
} @Override public void onReceive(Context context, Intent intent)
{ Log.e("RECEIVE", "Start 2");
if (intent.getAction().equals(ACTION_WIDGET_RECEIVER))
try Log.e("SIZE", "Size Of channel array: "+channelsImages.size());
} catch(Exception e)
Log.e("ON_RECIEVE_ERROR", " "+e.getMessage());
super.onReceive(context, intent);
Log.e("RECEIVE", "End");
View 2 Replies
View Related
Jul 31, 2009
I use the BroadcastReceiver to get the MMS information, but the onReceive can not get the message when MMS coming.
Code as following: Code...
This code can work when SMS coming. Does anybody give me some comments?
View 3 Replies
View Related
Aug 13, 2010
In my understand, Anroid app supports only SPP connection not HFP and A2DP. However, I want to initiate HFP and A2DP connection in Android app just like selecting Bluetooth device in Bluetooth Settings menu. I'm not sure it is possible to use a intent including BluetothDevice object, so the intent receiver can initiate HFP and A2DP connection. If you have a idea, could you let me know that?
View 1 Replies
View Related
Sep 2, 2010
I have an application and i want this application should be listed in Setting screen and can be initiate from there as a separate process. How i can do the same.
View 2 Replies
View Related
Nov 7, 2010
I basically want to make and intent and pass to a service from my BroadcastReceiver's onReceive(). So far I always used View.getContext(), but here, I'm stuck. How exactly can I get the context so I can use public Intent (Context packageContext, Class<?> cls). Or is there any other way I can create an Intent and send to a service?
View 1 Replies
View Related
Jan 3, 2010
Supposedly the HTC Hero (Sprint) is capable of voice dialing but I do not see any mention of it the user manual. Does it do it? And, if so, how do you initiate it?
View 10 Replies
View Related
Oct 7, 2010
Is it possible to initiate an outgoing call without having the phone invoke it's default dialing screen? The point is to be able to make a call without someone knowing I'm making a call.
View 1 Replies
View Related
Jun 18, 2013
My Samsung Galaxy S4 has started popping up the message "An error has occurred in onReceive" every few hours.
If an app is the culprit, how can it be identified? I am an end user, not a developer.
View 6 Replies
View Related
Jun 6, 2013
The Situation or: what I'm looking for:
1. Nexus 7 with Google Contacts app
2. Non-android phone (Nokia N8 etc.) or really any dumb phone paired to Nexus 7 via bluetooth.
3. Select phone number from Contacts on Nexus 7 -> connected phone dials the number
4. Talk on phone.
As I have a very extensive and nicely organized list of contacts in my "People" app (Google Contacts) on the Nexus 7, I would just like to be able to select a number there and have the bluetooth-connected dumb phone place the call, so I just need to pick up the phone and talk, not dial the number manually on the phone.
Right now, when I select a number in the Contacts app on the Nexus 7, Skype - of all things - starts and wants to dial that number apparently. Instead of Skype, I want the number to be sent to the connected bluetooth phone. Surely that HAS to be possible somehow?
Even though this should only require a simple ATD command to be sent out via bluetooth and it's a functionality that every automobile bluetooth setup can do (dial from the steering wheel etc. -> connected phone places the call), I couldn't find one single, small app that does that.
In the PC world, this is sometimes known as CTI (computer telephony integration), basically you dial a number on your Windows PC (e.g. using on-board "dialer.exe" or using Outlook, and your phone places the call). So now I'm basically looking for a simple, one-way TTI (tablet telephone integration).
I did find Tablet Talk, which looks very nice, but this one needs a client software to be installed on the phone, which therefore has to be Android, so it's unusable for my case. I'm pretty much looking for a universal solution here, i.e. Android tablet to any dumb or smart bluetooth-enabled phone (or even another android for that matter), which, given that bluetooth is a universally specified protocol, shouldn't be much of a problem, in my limited understanding.
From my point of view, to problems or "routines" would have to be solved/written in an app that does this:
1.) Get the Google Contacts app ("People") on the android tablet to send numbers via bluetooth or to our "middleware app" (to be named) instead of sending those numbers to the Skype app (which might just be a quirky configuration on my Nexus 7, but it illustrates the use case).
2.) ATD command to phone via bluetooth, sent from the tablet
View 1 Replies
View Related
Jun 13, 2010
whenever I recreate the home screen widget on my phone, the onReceive() method is not called.the problem would be that it doesn't respond to Button press that I assign which its function resides in the onReceive method. The issue does not reside on the emulator but when I tested it with my phone, it doesnt respond to it.
View 1 Replies
View Related
Sep 7, 2010
I'm trying to override the onBackPressed() method of the ActivityGroup class:
public class MyClass extends ActivityGroup {
@Override
public void onBackPressed() {
// do something
return;
}
but I'm getting the error The method onBackPressed() of type MyClass must override a superclass method. I'm relatively new to Java, I've seen here that people do it and it works for them Why I'm getting this error? I'm writing an app for android 1.5, could the problem be here?
View 1 Replies
View Related
Nov 22, 2010
In Eclipse, when I mouse hover over a built-in method, it displays a method definition including stuff like what the method does, input objects, return objects etc. If I have a yellow line (warning) under the method I'm trying to use, I can't get the mouse-over to show the definition. If I try hitting F3, I get a "The Jar of this class file belongs to container "Android 1.6" How do I show the definition of the method I am using when there is a warning?
View 1 Replies
View Related
May 12, 2010
I am trying to use annotation - method.getAnnotation( ) or method.isAnnotationPresent( ) and it is not working. I am using eclipse emulator for 2.1 OS version with JDK 1.6. Following is information about what I did..................
View 4 Replies
View Related
Mar 5, 2010
I am writing my own sms receiver app and i want it to catch all the sms using a broadcast receiver. This on its own, is no problem, but i want to be able to stop the message being passed to the messaging app.
View 2 Replies
View Related
Jun 20, 2010
A feature I miss on my Palm Pre was the ability to initiate a call on the phone and transfer call to bluetooth in my car or vice versa with the single click of a button.
I'm really having a difficult time with the Evo regarding this issue. Once I start the call on my phone, how do I transfer the call to my car without hanging up and calling through the car?
View 2 Replies
View Related
Apr 7, 2009
My use case is to launch one of settings app screen when I receive a certain event in idle state. For which, I added my new intent to PhoneAppBroadcastReceiver() in PhoneApp.java (looks like this receiver handles the misc intents) But when i call startActivity(), The phone seems to go into a panic ex. startActivity(new Intent(this, NetworkSetting.class)); My questions are is this the right approach to go about ? If so 1. How can I launch the activity inside of broadcastReceiver? secondly 2. How do i verify if the activity i want to start is already started?Can the NEW_TASK_LAUNCH be used to verify this ,
View 2 Replies
View Related
Sep 21, 2010
I have written an application to read all incoming SMS and if the SMS contains certain string, I will also send a copy of the message to my another phone for backup purposes.
I used the reference from the following website:
http://www.anddev.org/novice-tutorials-f8/recognize-react-on-incoming...
It uses BroadcastReceiver to get the incoming SMS, but when I tried to send it using the following method:
CODE:.............
It always crashes. Any idea how to resolve it? Is it because of using BroadcastReceiver.
View 4 Replies
View Related
Oct 2, 2009
I have an app widget that extends an AppWidgetProvider to create an application widget.
I would like the application widget to be idle until an activity in my app runs; actually when a service in my app is started.
Once that service is started, I need to "wake up" the application widget and communicate with it (i.e. tell it things to display).
So I see that AppWidgetProvider simply extends BroadcastReceiver -- so does that mean:
1. I need to call registerReceiver in my service and tell it to filter for certain kinds of events?
2. Can I even do #1, or will an AppWidgetProvider *only* accept ACTION_APPWIDGET_* intents?
3. If #2 is correct, how can I communicate or "wake up" / trigger the application widget?
4. Can I send events to my app widget using sendBroadcast( intent )?
Then, my app widget has some buttons on it, I need to send an intent back to the application (or service). I see you can do that with PendingIntents, but if i send the different intents it to the same Activity, it seems to re-use the first created pending intent.
View 2 Replies
View Related
Aug 6, 2009
I want to start a project which contains a BroadcastReceiver and an Activity. The BroadcastReceiver doesn't communicate with the activity. But they share a same resource. Can i do it in only one Project (that means, i use only 1 apk to install both BroadcastReceiver and the Activity on my phone), or i have to develope them seperately in 2 projects.
View 3 Replies
View Related
Aug 28, 2009
Can I Receive a Broadcast from a Service? It seem I have to extend BroadcastReceiver to receive broadcasts but I'm already extending Service and I can't extend 2 classes. Do I set up an additional Activity to receive broadcasts and then just pass stuff to the already running Service. And if so, how to I pass additional info to an existing Service? Is there a better way?
View 4 Replies
View Related
Jun 22, 2010
How can I best implement a BroadcastReceiver that may need to "consume" the current broadcast (via abortBroadcast()), but it first needs to perform some non-trivial work to determine whether or not the broadcast should be consumed.
The problem is that if the non-trivial work takes more than 10 seconds then the receiver is considered to be blocked by the system and may be killed.
I realise that long-running operations should not be performed in the onReceive() method of receivers for that very reason, and should instead be handed-off to an appropriate service. However, if the current broadcast is to be consumed, then the abortBroadcast() method must be called within the onReceive() method before it returns. If some processing is required to determine whether the current broadcast should be consumed or not, then things can get tricky.
I'm developing an app that can consume some (but not all) inbound SMS messages. For any given SMS message it will need to perform some analysis based on the sender's phone number and the message body (including database lookups) in order to determine if the message is one that is relevant to the app or not. In the vast majority of cases this will take less than 10 seconds, but it is possible that it could take longer on rare occasions.
To get around this I'm considering the following solution.
1. On receiving a broadcast for a received SMS, my receiver starts a background thread to perform the required analysis and handle the message if appropriate. 2. The main thread (currenly executing the onReceive() method) waits until either the background thread has finished its work, or 8 seconds have elapsed, whichever occurs first. 3. If the background thread finished within the allotted time (which should happen most of the time), then the main thread calls abortBroadcast() or not, (depending on the result of the analysis) and returns normally. 4. If the background thread did NOT finish within 8 seconds, then the main thread stops the background thread and instead starts a service to perform the work. In this case it does NOT call abortBroadcast(), and the broadcast will be passed to other receivers (eg the default messaging app) regardless of whether or not the service ends up handling the message. While not an ideal outcome, it is acceptable.
View 4 Replies
View Related
Dec 29, 2009
I'd like my app to catch incoming SMS messages. There are a few examples of this around. Looks like we just need to do this:
code:..........
Is this correct? I'm sending my phone some sms messages, but the log statement never gets printed. I do have some other SMS applications installed on the phone, which display a popup when the sms is received - are they somehow blocking the intent from getting passed down to my app, they are just consuming it completely?
View 2 Replies
View Related
Jun 2, 2010
I have seen several examples on how to implement a BroadCastReceiver, but how should I implement a Service who has to react on some pending Intent (for example incoming phone call)...Actually I was wondering about the same "prbolem" but in an Activity..You obviously have a class which extends a Service 9or an Activity) so it cannot also extend BroadCastReceiver...It looks like we cannot make "platform-awar" services and/or Activties ?
View 2 Replies
View Related