在我的Android應用程序中,除了當我點擊主頁按鈕並等待10-15分鐘並回到應用程序時,屏幕一片空白,一切都很完美。我仍然可以訪問菜單項,但屏幕只是黑色。Android onResume空白屏幕
如果我的行爲爲正常,選擇本地按鈕,然後回過頭來應用它是好的......它已經坐了一會兒後,其只...
任何想法?
我將Toast消息放在應用程序恢復時的途中,它使得它一直到最後一次執行代碼。所以我不知道發生了什麼。
而且,當屏幕是空白的,按回或家庭導致強制關閉
編輯:添加例外,點擊主頁按鈕時:
04-25 15:12:09.625: E/AndroidRuntime(6351): java.lang.RuntimeException: Unable to pause activity {com.MyApp/com.MyAppMain.MainScreen}: java.lang.NullPointerException
04-25 15:12:09.625: E/AndroidRuntime(6351): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2731)
04-25 15:12:09.625: E/AndroidRuntime(6351): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2678)
04-25 15:12:09.625: E/AndroidRuntime(6351): at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2651)
04-25 15:12:09.625: E/AndroidRuntime(6351): at android.app.ActivityThread.access$1700(ActivityThread.java:132)
04-25 15:12:09.625: E/AndroidRuntime(6351): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1045)
04-25 15:12:09.625: E/AndroidRuntime(6351): at android.os.Handler.dispatchMessage(Handler.java:99)
04-25 15:12:09.625: E/AndroidRuntime(6351): at android.os.Looper.loop(Looper.java:150)
04-25 15:12:09.625: E/AndroidRuntime(6351): at android.app.ActivityThread.main(ActivityThread.java:4263)
04-25 15:12:09.625: E/AndroidRuntime(6351): at java.lang.reflect.Method.invokeNative(Native Method)
04-25 15:12:09.625: E/AndroidRuntime(6351): at java.lang.reflect.Method.invoke(Method.java:507)
04-25 15:12:09.625: E/AndroidRuntime(6351): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-25 15:12:09.625: E/AndroidRuntime(6351): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-25 15:12:09.625: E/AndroidRuntime(6351): at dalvik.system.NativeStart.main(Native Method)
04-25 15:12:09.625: E/AndroidRuntime(6351): Caused by: java.lang.NullPointerException
04-25 15:12:09.625: E/AndroidRuntime(6351): at com.MyAppMain.MainScreen.onPause(MainScreen.java:110)
04-25 15:12:09.625: E/AndroidRuntime(6351): at android.app.Activity.performPause(Activity.java:3935)
04-25 15:12:09.625: E/AndroidRuntime(6351): at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1313)
04-25 15:12:09.625: E/AndroidRuntime(6351): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2708)
04-25 15:12:09.625: E/AndroidRuntime(6351): ... 12 more
import localytics.localytics.android.LocalyticsSession;
進口android.app.Activity; import android.content.Intent; import android.location.Location; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.ImageButton; import android.widget.Toast; import com.myapp.R; import com.WhiteLabel.tools.Globals; import com.WhiteLabel.tools.LocationService.LocationResult; import com.WhiteLabel.tools.PreferenceHelper;
public class LoadingScreen extends Activity 保護位置currentLocation; 私有ApplicationClass應用程序; 私人ImageButton btnLocal; private ImageButton btnNational; private ImageButton btnDOD; 私人ImageButton btnDestinations; private LocalyticsSession localyticsSession;
@Override
public void onCreate(Bundle savedInstanceState)
{
try
{
//final Activity activity = this;
application = ApplicationClass.getInstance();
setTheme(application.appTheme);
super.onCreate(savedInstanceState);
setContentView(R.layout.loading_screen);
application.addressSaved = false;
InitializeControls();
// String notifytime = PreferenceHelper.GetNotificationTime(this);
InitializeLocalytics(true);
Toast.makeText(this, "Use the menu button to access your account.", Toast.LENGTH_LONG).show();
}
catch(Exception ex)
{
String s = ex.toString();
}
}
@Override
protected void onResume()
{
try
{
super.onResume();
//if(!Globals.isRelease)
//Toast.makeText(this, "Hit onresume on loading screen.", Toast.LENGTH_LONG).show();
if(this.localyticsSession!=null)
this.localyticsSession.open();
Intent extrasIntent = getIntent();
if(extrasIntent!=null)
{
Bundle extras = extrasIntent.getExtras();
if(extras!=null)
{
String message = extras.getString("load_directive");
if(message.equalsIgnoreCase("notification"))
{
getIntent().putExtra("load_directive", "");
String s = message;
GetDDClick();
}
}
}
if(!Globals.isRelease)
Toast.makeText(this, "Hit after extras intent.", Toast.LENGTH_LONG).show();
//TODO - check for null application obj
if(application.loadFailed)
{
application.loadFailed = false;
Toast.makeText(getBaseContext(), "Connection issue. Please verify you are connected to the internet!", Toast.LENGTH_LONG).show();
}
if(!Globals.isRelease)
Toast.makeText(this, "Hit end of onresume.", Toast.LENGTH_LONG).show();
}
catch(Exception ex)
{
if(!Globals.isRelease)
Toast.makeText(this, "onResume error: "+ex.toString(), Toast.LENGTH_LONG).show();
}
}
public void onPause()
{
try
{
this.localyticsSession.close();
this.localyticsSession.upload();
}
catch(Exception ex)
{
if(!Globals.isRelease)
Toast.makeText(this, "onPause error:"+ex.toString(), Toast.LENGTH_LONG).show();
}
super.onPause();
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState)
{
super.onSaveInstanceState(savedInstanceState);
// your stuff or nothing
}
@Override
public void onRestoreInstanceState(Bundle savedInstanceState)
{
super.onRestoreInstanceState(savedInstanceState);
// your stuff or nothing
}
private void InitializeControls()
{
btnLocal = (ImageButton)findViewById(R.id.btnLocal);
btnNational = (ImageButton)findViewById(R.id.btnNational);
btnDOD = (ImageButton)findViewById(R.id.btnDOD);
btnDestinations = (ImageButton)findViewById(R.id.btnDestinations);
btnLocal.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { GetLocalClick(); }});
btnNational.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { GetNationalClick(); }});
btnDOD.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { GetDDClick(); }});
btnDestinations.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { GetDestinationsClick(); }});
}
private void InitializeLocalytics(Boolean instantiate)
{
if(instantiate)
this.localyticsSession = new LocalyticsSession(this.getApplicationContext(),Globals.LocalyticsAppKey);
this.localyticsSession.open(); // open the session
this.localyticsSession.tagScreen("Main Menu");
this.localyticsSession.upload(); // upload any data
}
private void GetLocalClick()
{
application.loadingButtonPressed = "local";
// set application var to local
GoToDDView();
}
private void GetNationalClick()
{
application.loadingButtonPressed = "national";
application.currentDivision = "national";
// set application var to national
GoToDDView();
}
private void GetDDClick()
{
application.loadingButtonPressed = "daily";
GoToSelectedView();
}
private void GetDestinationsClick()
{
application.loadingButtonPressed = "travel";
GoToDDView();
}
private void GoToDDView()
{
Intent getResultsWindow = new Intent(LoadingScreen.this, Daily.class);
startActivity(getResultsWindow);
}
private void GoToSelectedView()
{
Intent getResultsWindow = new Intent(LoadingScreen.this, DailySelected.class);
startActivity(getResultsWindow);
}
private void GoToHomeServices()
{
Intent getResultsWindow = new Intent(LoadingScreen.this, MainMenu.class);
startActivity(getResultsWindow);
}
private void GoToMyAccount()
{
Intent configIntent = new Intent(this,MyAccount.class);
startActivity(configIntent);
}
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.loadingscreenmenu, menu);
return true;
}
public boolean onOptionsItemSelected (MenuItem item)
{
switch (item.getItemId())
{
case R.id.PROFILE:
GoToMyAccount();
return true;
case R.id.MYVOUCHERS:
Intent loadVouchersIntent = new Intent(this, Vouchers.class);
startActivity(loadVouchersIntent);
return true;
}
return false;
}
}
你能從FC發佈堆棧跟蹤嗎? – 2012-04-25 18:51:48
嗯,可能有助於發佈logcat從部隊關閉?它可能會給我們一些線索。發佈一些onCreate/onResume可能也有幫助。 – Gophermofur 2012-04-25 18:53:21
好吧我從logcat得到的例外,並張貼它上面 – Jesse 2012-04-25 19:18:32