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 8021123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:53:09+00:00 2026-06-04T21:53:09+00:00

I have written a small code for usb detection for android device but its

  • 0

I have written a small code for usb detection for android device but its crashing while I connect the device cable to CPU of my computer

Here is my code

public class IntentReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {

        // TODO Auto-generated method stub

        if(intent.getAction().equals(Intent.ACTION_UMS_CONNECTED))

        {

            Toast.makeText(context, "mounted", Toast.LENGTH_LONG).show();
            Log.i("ANDROID DEVICE IS","CONNECTED");
            System.out.println(" ANDROID DEVICE IS CONNECTED");
            // Intent myStarterIntent = new Intent(context, CarHome.class);
            //   myStarterIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            //   context.startActivity(myStarterIntent);
        }

        else if(intent.getAction().equals(Intent.ACTION_UMS_DISCONNECTED)){

            Toast.makeText(context, "Unmounted", Toast.LENGTH_LONG).show();
            Log.i("ANDROID DEVICE IS","DISCONNECTED");  
            System.out.println(" ANDROID DEVICE IS NOT CONNECTED");
        }
    }

}

Manifest file is here

<receiver android:name=".IntentReceiver">
    <intent-filter>
      <action android:name="android.intent.action.ACTION_UMS_CONNECTED" />
      <action android:name="android.intent.action.ACTION_UMS_DISCONNECTED" />
      <action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
    </intent-filter>
</receiver>

Logcat showing these errors

05-25 15:30:08.350: E/AndroidRuntime(3457):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:1785)
05-25 15:30:08.350: E/AndroidRuntime(3457):     at android.app.ActivityThread.access$2400(ActivityThread.java:121)
05-25 15:30:08.350: E/AndroidRuntime(3457):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993)
05-25 15:30:08.350: E/AndroidRuntime(3457):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-25 15:30:08.350: E/AndroidRuntime(3457):     at android.os.Looper.loop(Looper.java:130)
05-25 15:30:08.350: E/AndroidRuntime(3457):     at android.app.ActivityThread.main(ActivityThread.java:3701)
05-25 15:30:08.350: E/AndroidRuntime(3457):     at java.lang.reflect.Method.invokeNative(Native Method)
05-25 15:30:08.350: E/AndroidRuntime(3457):     at java.lang.reflect.Method.invoke(Method.java:507)
05-25 15:30:08.350: E/AndroidRuntime(3457):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
05-25 15:30:08.350: E/AndroidRuntime(3457):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
05-25 15:30:08.350: E/AndroidRuntime(3457):     at dalvik.system.NativeStart.main(Native Method)
05-25 15:30:08.350: E/AndroidRuntime(3457): Caused by: java.lang.ClassNotFoundException: com.kk88655.hello.IntentReceiver in loader dalvik.system.PathClassLoader[/data/app/com.kk88655.hello-2.apk]
05-25 15:30:08.350: E/AndroidRuntime(3457):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
05-25 15:30:08.350: E/AndroidRuntime(3457):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
05-25 15:30:08.350: E/AndroidRuntime(3457):     at  java.lang.ClassLoader.loadClass(ClassLoader.java:511)

Latest logcat messages

05-25 17:51:32.878: E/AndroidRuntime(5602): FATAL EXCEPTION: main
05-25 17:51:32.878: E/AndroidRuntime(5602): java.lang.RuntimeException: Unable to instantiate receiver com.kk88655.hello.IntentReceiver: java.lang.ClassNotFoundException: com.kk88655.hello.IntentReceiver in loader dalvik.system.PathClassLoader[/data/app/com.kk88655.hello-1.apk]
05-25 17:51:32.878: E/AndroidRuntime(5602):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:1785)
05-25 17:51:32.878: E/AndroidRuntime(5602):     at android.app.ActivityThread.access$2400(ActivityThread.java:121)
05-25 17:51:32.878: E/AndroidRuntime(5602):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993)
05-25 17:51:32.878: E/AndroidRuntime(5602):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-25 17:51:32.878: E/AndroidRuntime(5602):     at android.os.Looper.loop(Looper.java:130)
05-25 17:51:32.878: E/AndroidRuntime(5602):     at android.app.ActivityThread.main(ActivityThread.java:3701)
05-25 17:51:32.878: E/AndroidRuntime(5602):     at java.lang.reflect.Method.invokeNative(Native Method)
05-25 17:51:32.878: E/AndroidRuntime(5602):     at java.lang.reflect.Method.invoke(Method.java:507)
05-25 17:51:32.878: E/AndroidRuntime(5602):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
05-25 17:51:32.878: E/AndroidRuntime(5602):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
05-25 17:51:32.878: E/AndroidRuntime(5602):     at dalvik.system.NativeStart.main(Native Method)
05-25 17:51:32.878: E/AndroidRuntime(5602): Caused by: java.lang.ClassNotFoundException: com.kk88655.hello.IntentReceiver in loader dalvik.system.PathClassLoader[/data/app/com.kk88655.hello-1.apk]
05-25 17:51:32.878: E/AndroidRuntime(5602):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
05-25 17:51:32.878: E/AndroidRuntime(5602):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
05-25 17:51:32.878: E/AndroidRuntime(5602):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
05-25 17:51:32.878: E/AndroidRuntime(5602):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:1776)
05-25 17:51:32.878: E/AndroidRuntime(5602):     ... 10 more
05-25 17:51:32.878: W/ActivityManager(238):   Force finishing activity com.kk88655.hello/.CarHome
  • 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-04T21:53:11+00:00Added an answer on June 4, 2026 at 9:53 pm

    You should read the docs:

    ACTION_UMS_CONNECTED

    This constant is deprecated. replaced by
    android.os.storage.StorageEventListener

    Broadcast Action: The device has entered USB Mass Storage mode. This
    is used mainly for the USB Settings panel. Apps should listen for
    ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts
    to be
    notified when the SD card file system is mounted or unmounted


    Against your ClassNotFoundException:

    In your manifest, you prefixed the class-name of your BoradcastReceiver with a period, which is a shortcut. It will take the package-name you specified in your <manifest>-tags package-attribute and add the given class-name to it.

    So, you should make sure that your fully qualified class-path is com.kk88655.hello.IntentReceiver, because it seems that you renamed the hello-package to hello2 (as seen in the logcat: /data/app/com.kk88655.hello-2.apk).


    A similar question has already been asked here: Android Broadcast Receiver Error: Class not found exception with no accepted or up-voted answer so far.

    Another idea would be to specify the fully-qualified package-name in the <receiver>-tags android:name-attribute, as suggested here: Unable to instantiate receiver in BroadcastReceiver SMS

    Another explanation might be an update-issue with your older application-version as discussed here: ClassNotFoundException error reports when upgrading Android app Reading this question, it also might be an App2SD problem.

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

Sidebar

Related Questions

I have written a small piece of code to calculate quadratic equations, but if
I have written a small plugin to change the text size but it doesn't
I have written a small function, which uses ElementTree to parse xml file,but it
Hi all i have written a small code to open a particular text file.
Here i have written a small code...in this looping is not done..only first image
I have written a small piece of code which handles the input of a
I have written some code in which a small part of the code takes
I have written a small Android Demo to use TTS in different languages. I
i have written a small piece of code. This code first blocks the {SIGSEGV},
I have written a small piece of code regarding the dynamic loading of assemblies

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.