Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.your.example;
- import android.content.BroadcastReceiver;
- import android.content.Context;
- import android.content.Intent;
- import android.widget.Toast;
- import android.util.Log; // Add this line
- public final class StatusCheckStarter extends BroadcastReceiver {
- static Context myActivity;
- private static StatusCheckStarter instance;
- public static String text = "hello world";
- public static void makeToast() {
- Toast.makeText(myActivity, text, Toast.LENGTH_LONG).show();
- }
- public static void receiveActivityInstance(Context tempActivity) {
- myActivity = tempActivity;
- Log.d("StatusCheckStarter", "Activity reference received.");
- }
- public static void StartCheckerService() {
- Log.d("StatusCheckStarter", "Attempting to start LocationPlugin service.");
- myActivity.startService(new Intent(myActivity, LocationPlugin.class));
- }
- public static void StopCheckerService() {
- Log.d("StatusCheckStarter", "Stopping LocationPlugin service.");
- myActivity.stopService(new Intent(myActivity, LocationPlugin.class));
- }
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.d("StatusCheckStarter", "Broadcast received."); // Log statement added
- String sentIntent = intent.getStringExtra(Intent.EXTRA_TEXT);
- if (sentIntent != null) {
- text = sentIntent;
- Toast.makeText(myActivity, "Received number: " + sentIntent, Toast.LENGTH_LONG).show();
- }
- }
- public static void createInstance() {
- if (instance == null) {
- instance = new StatusCheckStarter();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement