I am trying to call a method (postMessage) through a broadcastReceiver by Passing the context but is not working.
What is the mistake ? I tried many things but still not working.
I make a simple Android Apps that will update its view when an SMS is received.
I have a receiver that is called whenever an SMS is received
public class SMSReceiver extends BroadcastReceiver
{
private SharedPreferences prefs;
private String prefName = "MyPref";
private static final String NUMBER_KEY = "number";
@Override
public void onReceive(Context context, Intent intent)
{
//---get the SMS message passed in---
Bundle bundle = intent.getExtras();
SmsMessage
this is my code for setting alarm:
public void SetAlarm(Context context, int tag, long time){
AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(context, Alarm.class);
i.putExtra("position", tag);
PendingIntent pi = PendingIntent.getBroadcast(context, tag, i, PendingIntent.FLAG_CANCEL_CURRENT);
am.set(AlarmManager.RTC_WAKE
I want to show a list and shows its detailed view click on items.Here is my code
public class MyView extends RelativeLayout {
private LinearLayout contentLayout;
private Context context = null;
private View contentView = null;
private LayoutInflater layoutInflater = null;
private DetailsView detailView = null;
public MyView(Context context) {
super(context);
In my broadcast receiver activity I need to run some code when an alert is fired which I can get working no problem, but I need to make sure my Map activity is on the screen when this code is run, so I am trying to start the Map activity with an intent but this crashes the application and I do not know why.
I am trying to setup a BroadcastReceiver to handle scheduled events. I have been following http://mobile.tutsplus.com/tutorials/android/android-fundamentals-schedu... , and had the feature working, or so I believed.
I have next problem:
I create a custom BroadcastReceiver and register it in main activity onCreate handler:
public class MainActivity extends ListActivity {
private static final LogReceiver logReceiver = new LogReceiver();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LocalBroadcastManager.getInstance(this).registerReceiver(logRece
the deleteDatabase method needs a context in order to work. So in my class there is a context declared called ourContext. This class does not extend any other class like
Activity so I guess you could call it a helper class.
The only place in the class that uses context is the one method shown below that is called deleteData.