Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8447869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:16:59+00:00 2026-06-10T10:16:59+00:00

the code for the broadcast receiver is public class MyBroadcastreceiver extends BroadcastReceiver { public

  • 0

the code for the broadcast receiver is

public class MyBroadcastreceiver extends BroadcastReceiver {

public void onReceive(Context context, Intent intent) {
    Intent startServiceIntent = new Intent(context, MyService.class);
    startServiceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startService(startServiceIntent);

   }
 }

the code for the service is

public class MyService extends Service {

 String tag="TestService";
 @Override
  public void onCreate() {

     Toast.makeText(this, "Service created...", Toast.LENGTH_LONG).show();      
  // Log.i(tag, "Service created...");
    }

   @Override
   public void onStart(Intent intent, int startId) {      
   super.onStart(intent, startId);  
   Intent dialogIntent = new Intent(getBaseContext(), LocationStat.class);
   dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   getApplication().startActivity(dialogIntent);
   }

  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {

   Toast.makeText(this,"task perform in service",Toast.LENGTH_LONG).show();
  /* startActivity(new Intent(MyService.this,LocationStat.class));*/
     return super.onStartCommand(intent, flags, startId);
   }
   @Override
   public void onDestroy() {
   super.onDestroy();
   Toast.makeText(this, "Service destroyed...", Toast.LENGTH_LONG).show();
   }

   @Override
   public IBinder onBind(Intent intent) {
   return null;
   }
 }

and the activity that i am trying to start from the service is

public class LocationStat extends Activity {
double logi;
double lat;
long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 1; // in Meters
long MINIMUM_TIME_BETWEEN_UPDATES = 1000; // in Millisecon
Location loc;
LocationManager manager;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    manager=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
    manager.requestLocationUpdates(
            LocationManager.GPS_PROVIDER, 
            MINIMUM_TIME_BETWEEN_UPDATES, 
            MINIMUM_DISTANCE_CHANGE_FOR_UPDATES,
            new MyLocationListener()
    );
   Toast.makeText(this,"activity created...",Toast.LENGTH_LONG).show();
   loc=manager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

   String s;
   if(loc!=null)
   {
     logi=loc.getLongitude();
     lat=loc.getLatitude();
      s="Lat:" + lat + "\nLong:" + logi;

   }
   else
   {
    s ="no location found";
   }

   Toast.makeText(LocationStat.this,"Your Current Position is:\n" +
           s,Toast.LENGTH_LONG).show();
   webcall(logi,lat);
   //getLoc();

}
public void webcall(double logi,double lat)
    {
        InputStream is=null;
        String result = "";
        //the year data to send
        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("logitude",Double.toString(logi)));
        nameValuePairs.add(new BasicNameValuePair("latitude",Double.toString(lat)));

        //http post
        try{
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost("http://10.0.2.2/location.php");
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                HttpResponse response = httpclient.execute(httppost);
                HttpEntity entity = response.getEntity();
                is = entity.getContent();
        }catch(Exception e){
                Toast.makeText(LocationStat.this,"Error in http connection "+e.toString(),Toast.LENGTH_LONG).show();
        }
        //convert response to string
        try{
                BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
                StringBuilder sb = new StringBuilder();
                String line = null;
                while ((line = reader.readLine()) != null) {
                        sb.append(line + "\n");
                }
                is.close();

                 result=sb.toString();




                Toast.makeText(LocationStat.this,result,Toast.LENGTH_LONG).show();
        }catch(Exception e){
                Toast.makeText(LocationStat.this,"Error converting result       "+e.toString(),Toast.LENGTH_LONG).show();
        }

the manifest look like this

<service android:enabled="true" android:name=".MyService">
            <intent-filter >
                <action android:name="com.android.trace.MyService"/>

            </intent-filter>
        </service>

        <receiver android:name="com.android.trace.MyBroadcastReceiver">  
            <intent-filter>  
              <action android:name="android.intent.action.BOOT_COMPLETED" />  
             </intent-filter>  
        </receiver> 


    <activity
        android:name=".LocationStat"
        android:label="@string/title_activity_location_stat" >
        <intent-filter>
             <action android:name="android.intent.action.MAIN" />  

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>
 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> 

the logcat is:

08-28 06:47:07.388: E/AndroidRuntime(265): FATAL EXCEPTION: main
08-28 06:47:07.388: E/AndroidRuntime(265): java.lang.RuntimeException: Unable to instantiate receiver com.android.trace.MyBroadcastReceiver: java.lang.ClassNotFoundException: com.android.trace.MyBroadcastReceiver in loader dalvik.system.PathClassLoader[/data/app/com.android.trace-1.apk]
08-28 06:47:07.388: E/AndroidRuntime(265):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2789)
08-28 06:47:07.388: E/AndroidRuntime(265):  at android.app.ActivityThread.access$3200(ActivityThread.java:125)
08-28 06:47:07.388: E/AndroidRuntime(265):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
08-28 06:47:07.388: E/AndroidRuntime(265):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-28 06:47:07.388: E/AndroidRuntime(265):  at android.os.Looper.loop(Looper.java:123)
08-28 06:47:07.388: E/AndroidRuntime(265):  at android.app.ActivityThread.main(ActivityThread.java:4627)
08-28 06:47:07.388: E/AndroidRuntime(265):  at java.lang.reflect.Method.invokeNative(Native Method)
08-28 06:47:07.388: E/AndroidRuntime(265):  at java.lang.reflect.Method.invoke(Method.java:521)
08-28 06:47:07.388: E/AndroidRuntime(265):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-28 06:47:07.388: E/AndroidRuntime(265):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-28 06:47:07.388: E/AndroidRuntime(265):  at dalvik.system.NativeStart.main(Native Method)
08-28 06:47:07.388: E/AndroidRuntime(265): Caused by: java.lang.ClassNotFoundException: com.android.trace.MyBroadcastReceiver in loader dalvik.system.PathClassLoader[/data/app/com.android.trace-1.apk]
08-28 06:47:07.388: E/AndroidRuntime(265):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
08-28 06:47:07.388: E/AndroidRuntime(265):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
08-28 06:47:07.388: E/AndroidRuntime(265):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
08-28 06:47:07.388: E/AndroidRuntime(265):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2780)
08-28 06:47:07.388: E/AndroidRuntime(265):  ... 10 more

i have taken all the necessary permissions in the manifest for broadcast receiver and service but when the application start’s at boot up of device and force close immediately

please help me out, thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:17:01+00:00Added an answer on June 10, 2026 at 10:17 am

    use com.android.trace.MyBroadcastreceiver instead of com.android.trace.MyBroadcastReceiver in manifast.xml for Registering Broadcast Receiver.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to start a service using BroadcastReceiver with this code public void onReceive(Context
I have inner class as broadcast receiver: public class ManualBacklightReceiver extends BroadcastReceiver { public
This is my code: Activity: @Override public void onCreate(Bundle savedInstanceState) { ... Intent intent
Here is the test code that I am using : public class IOConnectDirect extends
public class FBPost extends Service{ private Bundle params = new Bundle(); private String userID=;
In my application, I have registered a broadcast receiver to receive the system intent
I just changed my external broadcast receiver class to my service since..some android method
i am doing an sms hiding project which is broadcast receiver the code is
I'm working with passive provider, with this code. Intent intent = new Intent(PASSIVE_ACTION); PendingIntent
I want to create a broadcast receiver as an inner class in my main

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.