Dear Parbhakar Could you please check view id following error: >05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at com.CallRecorder.CallRecorder. ><init>(CallRecorder.java:15)
Best Regards, DatNQ On Thu, May 26, 2011 at 11:17 PM, Parbhakar Bikkaneti < [email protected]> wrote: > > Am using the following code:--------------------- > > package com.CallRecorder; > > import java.io.IOException; > > import android.app.Activity; > import android.media.MediaPlayer; > import android.media.MediaRecorder; > import android.os.Bundle; > import android.util.Log; > import android.view.View; > import android.widget.Button; > > public class CallRecorder extends Activity { > > Button start=(Button) findViewById(R.id.start); > Button stop = (Button) findViewById(R.id.stop); > Button play=(Button) findViewById(R.id.play); > String PATH="/mnt/sdcard/aaa.3gp"; > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > final MediaRecorder recorder=new MediaRecorder(); > > start.setOnClickListener(new View.OnClickListener() { > @Override > public void onClick(View v) { > recorder.setAudioSource(MediaRecorder.AudioSource.MIC); > recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); > recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); > recorder.setOutputFile(PATH); > try { > recorder.prepare(); > } catch (IllegalStateException e) { > Log.i("Start Recording", "prepare failed 1"); > e.printStackTrace(); > } catch (IOException e) { > Log.i("Start Recording", "prepare failed 2"); > e.printStackTrace(); > } > recorder.start(); > } > }); > > stop.setOnClickListener(new View.OnClickListener() { > @Override > public void onClick(View v) { > recorder.stop(); > recorder.reset(); > recorder.release(); > } > }); > > play.setOnClickListener(new View.OnClickListener() { > @Override > public void onClick(View v) { > MediaPlayer mp=new MediaPlayer(); > try { > mp.setDataSource(PATH); > } catch (IllegalArgumentException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } catch (IllegalStateException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > try { > mp.prepare(); > } catch (IllegalStateException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > mp.start(); > } > }); > } > } > > > When am running the code the application is "force closing" > > The Log-report is: > > 05-26 21:45:35.041: WARN/dalvikvm(18659): threadid=1: thread exiting with > uncaught exception (group=0x4001d800) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): FATAL EXCEPTION: main > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): > java.lang.RuntimeException: Unable to instantiate activity > ComponentInfo{com.CallRecorder/com.CallRecorder.CallRecorder}: > java.lang.NullPointerException > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > android.app.ActivityThread.access$2300(ActivityThread.java:125) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > android.os.Handler.dispatchMessage(Handler.java:99) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > android.os.Looper.loop(Looper.java:123) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > android.app.ActivityThread.main(ActivityThread.java:4627) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > java.lang.reflect.Method.invokeNative(Native Method) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > java.lang.reflect.Method.invoke(Method.java:521) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > dalvik.system.NativeStart.main(Native Method) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): Caused by: > java.lang.NullPointerException > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > android.app.Activity.findViewById(Activity.java:1637) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > com.CallRecorder.CallRecorder.<init>(CallRecorder.java:15) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > java.lang.Class.newInstanceImpl(Native Method) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > java.lang.Class.newInstance(Class.java:1429) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > android.app.Instrumentation.newActivity(Instrumentation.java:1021) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): at > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577) > 05-26 21:45:35.140: ERROR/AndroidRuntime(18659): ... 11 more > 05-26 21:45:35.259: WARN/ActivityManager(74): Force finishing activity > com.CallRecorder/.CallRecorder > 05-26 21:45:36.029: WARN/ActivityManager(74): Activity pause timeout for > HistoryRecord{44f3c178 com.CallRecorder/.CallRecorder} > > > Thanks, for any help in advance. > > -- > > > > Regards, > Bikkanati Prabhakar. > E-Mail: [email protected] > Blog: http://LetsXploreIT.blogspot.com > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

