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

  • Home
  • SEARCH
  • 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 8190529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:40:54+00:00 2026-06-07T03:40:54+00:00

When I call this Record.java class via Intent from another class and then click

  • 0

When I call this Record.java class via Intent from another class and then click on the button1, i get a forced close exception. I want to know why this is happening. Also, the logcat says something like device disconnected “unable to create media player”

The code is:

public class Record extends Activity{
    Button btn1,btn2;
    MediaRecorder recorder;
     public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.record);
            btn1=(Button)findViewById(R.id.button1);
            btn2=(Button)findViewById(R.id.button2);
            btn1.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    recorder = new MediaRecorder();

                    recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
                    recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
                    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
                    recorder.setOutputFile("/sdcard/sample.3gp");


                    try {
                        recorder.prepare();
                        recorder.start();
                    } catch (IllegalStateException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            });
            btn2.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    recorder.stop();
                    recorder.reset();
                    recorder.release();

                    recorder = null;
                }
            });
     }

}

Here is the logcat output

  07-05 10:20:07.598: E/AndroidRuntime(841): Uncaught handler: thread main exiting due to uncaught exception
07-05 10:20:07.609: E/AndroidRuntime(841): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.newaa/com.example.newaa.Recipient}: java.lang.IndexOutOfBoundsException: charAt: -1 < 0
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.app.ActivityThread.access$2200(ActivityThread.java:119)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.os.Looper.loop(Looper.java:123)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.app.ActivityThread.main(ActivityThread.java:4363)
07-05 10:20:07.609: E/AndroidRuntime(841):  at java.lang.reflect.Method.invokeNative(Native Method)
07-05 10:20:07.609: E/AndroidRuntime(841):  at java.lang.reflect.Method.invoke(Method.java:521)
07-05 10:20:07.609: E/AndroidRuntime(841):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-05 10:20:07.609: E/AndroidRuntime(841):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-05 10:20:07.609: E/AndroidRuntime(841):  at dalvik.system.NativeStart.main(Native Method)
07-05 10:20:07.609: E/AndroidRuntime(841): Caused by: java.lang.IndexOutOfBoundsException: charAt: -1 < 0
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.text.SpannableStringBuilder.charAt(SpannableStringBuilder.java:110)
07-05 10:20:07.609: E/AndroidRuntime(841):  at com.example.newaa.Recipient$2.onTextChanged(Recipient.java:76)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.widget.TextView.sendOnTextChanged(TextView.java:6131)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.widget.TextView.setText(TextView.java:2687)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.widget.TextView.setText(TextView.java:2552)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.widget.EditText.setText(EditText.java:71)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.widget.TextView.setText(TextView.java:2527)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.widget.TextView.onRestoreInstanceState(TextView.java:2427)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.view.View.dispatchRestoreInstanceState(View.java:5940)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1127)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1127)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.view.View.restoreHierarchyState(View.java:5919)
07-05 10:20:07.609: E/AndroidRuntime(841):  at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1454)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.app.Activity.onRestoreInstanceState(Activity.java:835)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.app.Activity.performRestoreInstanceState(Activity.java:807)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1096)
07-05 10:20:07.609: E/AndroidRuntime(841):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2473)
  • 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-07T03:40:56+00:00Added an answer on June 7, 2026 at 3:40 am

    Your problem is in com.example.newaa.Recipient class.
    see this line number. at com.example.newaa.Recipient$2.onTextChanged(Recipient.java:76)
    Hope you will find problem or post the code of your Recipient.java

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

Sidebar

Related Questions

I call this a flash meeting, but maybe there is another more appropriate name.
So I call this PHP script from the command line: /usr/bin/php /var/www/bims/index.php projects/output and
Shouldn't I be able to call this CoffeeScript method from within an erb template?
I'm getting a java outOfMemoryError when I call this method - i'm using it
I'm calling importtsv from within a Java class and for some reason it's not
So I come from a background in Java where you can create a class
I have troubles reading an arraylist from a java class with jni. In the
I want to delete record from GridView.Before to this ask for confirmation like Are
If you decompile the java.lang.Class class in java from the rt.jar library you will
I want to call this WS http://www.webservicex.net/country.asmx?op=GetCountries What is the best possible way to

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.