Akiduki wrote:
> I am writing an application which one of the activity has a button and
> use this button to switch to another activity when clicking that. The
> main activity implements the onCreate and OnClickListener as follows:
> 
> public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
> 
>         startButton = (Button) findViewById(R.id.start_button);
>         startButton.setOnClickListener(mVideoListener);
>     }
> 
>     private OnClickListener mVideoListener = new OnClickListener(){
> 
>               @Override
>               public void onClick(View v) {
>                       // TODO Auto-generated method stub
>                       WriteFile();
>                       Intent intent = new 
> Intent(RatingPlayer.this.getApplication(),
> Inplayer.class);
>                       startActivity(intent);
>               }
> 
>     };
> 
> When I try to run this program on my emulator, after hitting the
> button, the program stopped unexpectedly. I follow the instructions of
> implementing OnClickListener firmly so I don't know what's the problem
> in my implementation.

Use adb logcat, DDMS, or the DDMS perspective in Eclipse to find the
Java stack trace that corresponds to this exception. That will help you
find the problem.

In this case, I would get rid of the getApplication() call and just use
RatingPlayer.this as your Context.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Development Wiki: http://wiki.andmob.org

-- 
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

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to