我正在编写从其他活动启动的活动。它获取有时会推出新的活动显示黑屏如果反复退出和重新启动屏幕Android应用程序在重复启动并退出后显示空白屏幕
下面这是越来越从另一个活动推出的活动中的onCreate():
@Override
protected void onCreate(Bundle savedInstanceState) {
if (!isTaskRoot()) {
final Intent intent = getIntent();
final String intentAction = intent.getAction();
if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && intentAction != null && intentAction.equals(Intent.ACTION_MAIN)) {
Log.w("onCreate()", "Main Activity is not the root. Finishing Main Activity instead of launching.");
finish();
return;
}
}
super.onCreate(savedInstanceState);
Log.d("onCreate()", "Calling setContentView()");
setContentView(R.layout.dial_screen);
name = (TextView) findViewById(R.id.name);
number = (TextView) findViewById(R.id.number);
duration = (TextView) findViewById(R.id.duration);
mute = (Button) findViewById(R.id.mute);
end = (ImageButton) findViewById(R.id.end);
}
而且这里是dial_screen.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/bg1024_600"
tools:context="com.harman.contacts.CallScreenActivity" >
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp"
android:text="@string/hello_world"
android:textSize="45sp"
android:textColor="@android:color/white" />
<TextView
android:id="@+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/name"
android:layout_marginTop="50dp"
android:text="@string/hello_world"
android:textSize="35sp"
android:textColor="@android:color/white" />
<TextView
android:id="@+id/duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/number"
android:layout_marginTop="50dp"
android:text="@string/dialling"
android:textSize="35sp"
android:textColor="@android:color/white" />
<LinearLayout
android:id="@+id/buttons"
android:layout_centerHorizontal="true"
android:layout_below="@id/duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="80dp">
<Button
android:id="@+id/mute"
android:layout_width="450dp"
android:layout_height="110dp"
android:text="@string/mute"
android:textSize="30sp"
android:textColor="@android:color/white"
android:layout_gravity="bottom"/>
<ImageButton
android:id="@+id/end"
android:layout_width="450dp"
android:layout_height="100dp"
android:layout_marginStart="30dp"
android:background="@drawable/end_call"
android:contentDescription="@string/hello_world"
android:layout_gravity="bottom"/>
</LinearLayout>
每次我收到日志之前的setContentView()(这意味着活动正确启动),但有时,即使获取日志后,布局也不会显示。 空白屏幕并不是每次都来,但有时候。任何想法,为什么这是和如何解决它?另外让我知道是否需要更多信息。
请让我知道为什么'-1'。在发布问题之前,我已经在网上搜索了足够的内容。在Android默认通话应用程序中也观察到类似的错误。然而,经过多次搜索,我找不到任何东西。帮助将不胜感激。 – SDG99 2015-03-25 10:56:05
我也得到了类似的东西。按回退出,我有一段空白的黑屏。我不得不一直重复按下应用程序才能完全退出:-( – user3833732 2016-06-18 10:32:33