Reputation: 1
here is the log, I am getting message in AVD like - unfortunately has stopped ,please help me solve this error, I want learn more in android but sucked by this error!
07-09 23:47:26.270: D/dalvikvm(831): Not late-enabling CheckJNI (already on)
07-09 23:47:29.460: I/Choreographer(831): Skipped 100 frames! The application may be doing too much work on its main thread.
07-09 23:47:30.160: D/gralloc_goldfish(831): Emulator without GPU emulation detected.
07-09 23:47:56.200: D/WiFiChangeBroadcastReceiver(831): WiFi Status Changed
07-09 23:47:56.530: D/WiFiChangeBroadcastReceiver(831): WiFi Status Changed
07-09 23:48:45.670: I/Choreographer(831): Skipped 222 frames! The application may be doing too much work on its main thread.
07-09 23:48:45.810: I/Choreographer(831): Skipped 39 frames! The application may be doing too much work on its main thread.
07-09 23:48:45.980: I/Choreographer(831): Skipped 212 frames! The application may be doing too much work on its main thread.
07-09 23:48:50.760: I/Choreographer(831): Skipped 190 frames! The application may be doing too much work on its main thread.
07-09 23:48:53.120: D/AndroidRuntime(831): Shutting down VM
07-09 23:48:53.120: W/dalvikvm(831): threadid=1: thread exiting with uncaught exception (group=0xb2aeaba8)
07-09 23:48:53.130: E/AndroidRuntime(831): FATAL EXCEPTION: main
07-09 23:48:53.130: E/AndroidRuntime(831): Process: com.example.beaglem, PID: 831
07-09 23:48:53.130: E/AndroidRuntime(831): java.lang.RuntimeException: Unable to pause activity {com.example.beaglem/com.example.beaglem.FullscreenActivity}: java.lang.NullPointerException
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3062)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3017)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2995)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.ActivityThread.access$1000(ActivityThread.java:135)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1213)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.os.Handler.dispatchMessage(Handler.java:102)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.os.Looper.loop(Looper.java:136)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.ActivityThread.main(ActivityThread.java:5017)
07-09 23:48:53.130: E/AndroidRuntime(831): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 23:48:53.130: E/AndroidRuntime(831): at java.lang.reflect.Method.invoke(Method.java:515)
07-09 23:48:53.130: E/AndroidRuntime(831): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
07-09 23:48:53.130: E/AndroidRuntime(831): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
07-09 23:48:53.130: E/AndroidRuntime(831): at dalvik.system.NativeStart.main(Native Method)
07-09 23:48:53.130: E/AndroidRuntime(831): Caused by: java.lang.NullPointerException
07-09 23:48:53.130: E/AndroidRuntime(831): at com.example.beaglem.FullscreenActivity.onPause(FullscreenActivity.java:185)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.Activity.performPause(Activity.java:5335)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1233)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3048)
07-09 23:48:53.130: E/AndroidRuntime(831): ... 12 more
07-09 23:57:25.030: D/gralloc_goldfish(1132): Emulator without GPU emulation detected.
07-09 23:57:25.490: I/Choreographer(1132): Skipped 297 frames! The application may be doing too much work on its main thread.
07-09 23:57:25.660: I/Choreographer(1132): Skipped 200 frames! The application may be doing too much work on its main thread.
07-09 23:47:26.270: D/dalvikvm(831): Not late-enabling CheckJNI (already on)
07-09 23:47:29.460: I/Choreographer(831): Skipped 100 frames! The application may be doing too much work on its main thread.
07-09 23:47:30.160: D/gralloc_goldfish(831): Emulator without GPU emulation detected.
07-09 23:47:56.200: D/WiFiChangeBroadcastReceiver(831): WiFi Status Changed
07-09 23:47:56.530: D/WiFiChangeBroadcastReceiver(831): WiFi Status Changed
07-09 23:48:45.670: I/Choreographer(831): Skipped 222 frames! The application may be doing too much work on its main thread.
07-09 23:48:45.810: I/Choreographer(831): Skipped 39 frames! The application may be doing too much work on its main thread.
07-09 23:48:45.980: I/Choreographer(831): Skipped 212 frames! The application may be doing too much work on its main thread.
07-09 23:48:50.760: I/Choreographer(831): Skipped 190 frames! The application may be doing too much work on its main thread.
07-09 23:48:53.120: D/AndroidRuntime(831): Shutting down VM
07-09 23:48:53.120: W/dalvikvm(831): threadid=1: thread exiting with uncaught exception (group=0xb2aeaba8)
07-09 23:48:53.130: E/AndroidRuntime(831): FATAL EXCEPTION: main
07-09 23:48:53.130: E/AndroidRuntime(831): Process: com.example.beaglem, PID: 831
07-09 23:48:53.130: E/AndroidRuntime(831): java.lang.RuntimeException: Unable to pause activity {com.example.beaglem/com.example.beaglem.FullscreenActivity}: java.lang.NullPointerException
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3062)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3017)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2995)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.ActivityThread.access$1000(ActivityThread.java:135)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1213)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.os.Handler.dispatchMessage(Handler.java:102)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.os.Looper.loop(Looper.java:136)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.ActivityThread.main(ActivityThread.java:5017)
07-09 23:48:53.130: E/AndroidRuntime(831): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 23:48:53.130: E/AndroidRuntime(831): at java.lang.reflect.Method.invoke(Method.java:515)
07-09 23:48:53.130: E/AndroidRuntime(831): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
07-09 23:48:53.130: E/AndroidRuntime(831): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
07-09 23:48:53.130: E/AndroidRuntime(831): at dalvik.system.NativeStart.main(Native Method)
07-09 23:48:53.130: E/AndroidRuntime(831): Caused by: java.lang.NullPointerException
07-09 23:48:53.130: E/AndroidRuntime(831): at com.example.beaglem.FullscreenActivity.onPause(FullscreenActivity.java:185)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.Activity.performPause(Activity.java:5335)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1233)
07-09 23:48:53.130: E/AndroidRuntime(831): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3048)
07-09 23:48:53.130: E/AndroidRuntime(831): ... 12 more
07-09 23:57:25.030: D/gralloc_goldfish(1132): Emulator without GPU emulation detected.
07-09 23:57:25.490: I/Choreographer(1132): Skipped 297 frames! The application may be doing too much work on its main thread.
07-09 23:57:25.660: I/Choreographer(1132): Skipped 200 frames! The application may be doing too much work on its main thread.
this is my main java ' private static final boolean AUTO_HIDE = true;
/**
* If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after
* user interaction before hiding the system UI.
*/
private static final int AUTO_HIDE_DELAY_MILLIS = 3000;
/**
* If set, will toggle the system UI visibility upon interaction. Otherwise,
* will show the system UI visibility upon interaction.
*/
private static final boolean TOGGLE_ON_CLICK = true;
/**
* The flags to pass to {@link SystemUiHider#getInstance}.
*/
private static final int HIDER_FLAGS = SystemUiHider.FLAG_HIDE_NAVIGATION;
/**
* The instance of the {@link SystemUiHider} for this activity.
*/
private SystemUiHider mSystemUiHider;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fullscreen);
final View controlsView = findViewById(R.id.fullscreen_content_controls);
final View contentView = findViewById(R.id.fullscreen_content);
// Set up an instance of SystemUiHider to control the system UI for
// this activity.
mSystemUiHider = SystemUiHider.getInstance(this, contentView, HIDER_FLAGS);
mSystemUiHider.setup();
mSystemUiHider
.setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() {
// Cached values.
int mControlsHeight;
int mShortAnimTime;
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public void onVisibilityChange(boolean visible) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
// If the ViewPropertyAnimator API is available
// (Honeycomb MR2 and later), use it to animate the
// in-layout UI controls at the bottom of the
// screen.
if (mControlsHeight == 0) {
mControlsHeight = controlsView.getHeight();
}
if (mShortAnimTime == 0) {
mShortAnimTime = getResources().getInteger(
android.R.integer.config_shortAnimTime);
}
controlsView.animate()
.translationY(visible ? 0 : mControlsHeight)
.setDuration(mShortAnimTime);
} else {
// If the ViewPropertyAnimator APIs aren't
// available, simply show or hide the in-layout UI
// controls.
controlsView.setVisibility(visible ? View.VISIBLE : View.GONE);
}
if (visible && AUTO_HIDE) {
// Schedule a hide().
delayedHide(AUTO_HIDE_DELAY_MILLIS);
}
}
});
// Set up the user interaction to manually show or hide the system UI.
contentView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (TOGGLE_ON_CLICK) {
mSystemUiHider.toggle();
} else {
mSystemUiHider.show();
}
}
});
// Upon interacting with UI controls, delay any scheduled hide()
// operations to prevent the jarring behavior of controls going away
// while interacting with the UI.
//findViewById(R.id.dummy_button).setOnTouchListener(mDelayHideTouchListener);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Trigger the initial hide() shortly after the activity has been
// created, to briefly hint to the user that UI controls
// are available.
delayedHide(100);
}
//----------------------------------------------------------------------------//
MediaPlayer playMusic;
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
//To check the Network Name or other info:
//WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
//WifiInfo wifiInfo = wifiManager.getConnectionInfo();
//int ipAddress = wifiInfo.getIpAddress();
// @SuppressWarnings("deprecation")
//String ipaddress = Formatter.formatIpAddress(ipAddress);
//{
//try{
//if("192.168.0.150".equals(ipaddress) );
//try
//{
//playMusic = new MediaPlayer();
//playMusic.setDataSource("http://192.168.0.134/audio/bbb1.php");
// playMusic.setOnPreparedListener(OnPreparedListener) this);
// playMusic = MediaPlayer.create(this, R.raw.testing);
// playMusic.prepare();
// playMusic.start();
}
//}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
playMusic.release();
}
/**
* Touch listener to use for in-layout UI controls to delay hiding the
* system UI. This is to prevent the jarring behavior of controls going away
* while interacting with activity UI.
*/
View.OnTouchListener mDelayHideTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (AUTO_HIDE) {
delayedHide(AUTO_HIDE_DELAY_MILLIS);
}
return false;
}
};
Handler mHideHandler = new Handler();
Runnable mHideRunnable = new Runnable() {
@Override
public void run() {
mSystemUiHider.hide();
}
};
/**
* Schedules a call to hide() in [delay] milliseconds, canceling any
* previously scheduled calls.
*/
private void delayedHide(int delayMillis) {
mHideHandler.removeCallbacks(mHideRunnable);
mHideHandler.postDelayed(mHideRunnable, delayMillis);
}
} '
Upvotes: 0
Views: 248
Reputation: 2317
The reason is you have all of the playMusic
code commented out except the playMusic.release()
code in the onPause method. You should be able to comment out that line and have it work.
If you look at the Stack Trace in the Log Cat file you'll see the following line:
07-09 23:48:53.130: E/AndroidRuntime(831): at com.example.beaglem.FullscreenActivity.onPause(FullscreenActivity.java:185)
This line told me where the Null Pointer Exception was happening (and looking at your code it's obvious that playMusic
is never being set, thus it's null).
Upvotes: 1