Java 我正在处理一个应用程序,该应用程序在启动屏幕后关闭,而下一个活动未加载
我正在开发一个过滤器应用程序,并创建了一个启动屏幕和另一个名为“ControlActivity”的活动,但一旦启动屏幕消失,应用程序将关闭,而不加载“ControlActivity”。 此外,关闭应用程序时不会出现任何错误 主要活动的代码为:-Java 我正在处理一个应用程序,该应用程序在启动屏幕后关闭,而下一个活动未加载,java,android,Java,Android,我正在开发一个过滤器应用程序,并创建了一个启动屏幕和另一个名为“ControlActivity”的活动,但一旦启动屏幕消失,应用程序将关闭,而不加载“ControlActivity”。 此外,关闭应用程序时不会出现任何错误 主要活动的代码为:- package com.example.harsh.filters; import android.content.Intent; import android.os.Handler; import android.support.v7.app.App
package com.example.harsh.filters;
import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(MainActivity.this, ControlActivity.class);
startActivity(intent);
}
},1000);
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:background="@android:color/white"
tools:context=".ControlActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:padding="12dp"
android:theme="?attr/actionBarTheme" />
<ImageView
android:id="@+id/centerImageView"
android:layout_width="match_parent"
android:layout_height="315dp"
android:layout_alignParentTop="true"
android:layout_marginTop="55dp"
app:srcCompat="@mipmap/img1"
tools:layout_below="@+id/toolbar"
tools:padding="16dp" />
<LinearLayout
android:id="@+id/controlLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/centerImageView"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="16dp"
tools:layout_below="@+id/centerImageView"
tools:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/uncheck" />
<SeekBar
android:id="@+id/seekBar2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<ImageView
android:id="@+id/imageView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/check" />
</LinearLayout>
<LinearLayout
android:id="@+id/thumbnailLinearLayout"
android:layout_width="match_parent"
android:layout_height="147dp"
android:orientation="horizontal"
android:padding="8dp"
tools:layout_below="@+id/controlLinearLayout">
<ImageView
android:id="@+id/imageView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/effect1" />
<ImageView
android:id="@+id/imageView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/effect2" />
<ImageView
android:id="@+id/imageView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/effect3" />
<ImageView
android:id="@+id/imageView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/effect4" />
</LinearLayout>
</RelativeLayout>
**The ControlActivity:-**
package com.example.harsh.filters;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
public class ControlActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_control);
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.harsh.filters">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ControlActivity"
android:label="@string/title_activity_control"
android:theme="@style/AppTheme.NoActionBar"></activity>
</application>
</manifest>
控制活动的XML代码:-
package com.example.harsh.filters;
import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(MainActivity.this, ControlActivity.class);
startActivity(intent);
}
},1000);
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:background="@android:color/white"
tools:context=".ControlActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:padding="12dp"
android:theme="?attr/actionBarTheme" />
<ImageView
android:id="@+id/centerImageView"
android:layout_width="match_parent"
android:layout_height="315dp"
android:layout_alignParentTop="true"
android:layout_marginTop="55dp"
app:srcCompat="@mipmap/img1"
tools:layout_below="@+id/toolbar"
tools:padding="16dp" />
<LinearLayout
android:id="@+id/controlLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/centerImageView"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="16dp"
tools:layout_below="@+id/centerImageView"
tools:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/uncheck" />
<SeekBar
android:id="@+id/seekBar2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<ImageView
android:id="@+id/imageView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/check" />
</LinearLayout>
<LinearLayout
android:id="@+id/thumbnailLinearLayout"
android:layout_width="match_parent"
android:layout_height="147dp"
android:orientation="horizontal"
android:padding="8dp"
tools:layout_below="@+id/controlLinearLayout">
<ImageView
android:id="@+id/imageView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/effect1" />
<ImageView
android:id="@+id/imageView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/effect2" />
<ImageView
android:id="@+id/imageView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/effect3" />
<ImageView
android:id="@+id/imageView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/effect4" />
</LinearLayout>
</RelativeLayout>
**The ControlActivity:-**
package com.example.harsh.filters;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
public class ControlActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_control);
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.harsh.filters">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ControlActivity"
android:label="@string/title_activity_control"
android:theme="@style/AppTheme.NoActionBar"></activity>
</application>
</manifest>
**控制活动:-**
包com.example.harsh.filters;
导入android.os.Bundle;
导入android.support.design.widget.FloatingActionButton;
导入android.support.design.widget.Snackbar;
导入android.support.v7.app.AppActivity;
导入android.support.v7.widget.Toolbar;
导入android.view.view;
公共类ControlActivity扩展了AppCompatActivity{
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u控件);
}
}
清单:-
package com.example.harsh.filters;
import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(MainActivity.this, ControlActivity.class);
startActivity(intent);
}
},1000);
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:background="@android:color/white"
tools:context=".ControlActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:padding="12dp"
android:theme="?attr/actionBarTheme" />
<ImageView
android:id="@+id/centerImageView"
android:layout_width="match_parent"
android:layout_height="315dp"
android:layout_alignParentTop="true"
android:layout_marginTop="55dp"
app:srcCompat="@mipmap/img1"
tools:layout_below="@+id/toolbar"
tools:padding="16dp" />
<LinearLayout
android:id="@+id/controlLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/centerImageView"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="16dp"
tools:layout_below="@+id/centerImageView"
tools:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/uncheck" />
<SeekBar
android:id="@+id/seekBar2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<ImageView
android:id="@+id/imageView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/check" />
</LinearLayout>
<LinearLayout
android:id="@+id/thumbnailLinearLayout"
android:layout_width="match_parent"
android:layout_height="147dp"
android:orientation="horizontal"
android:padding="8dp"
tools:layout_below="@+id/controlLinearLayout">
<ImageView
android:id="@+id/imageView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/effect1" />
<ImageView
android:id="@+id/imageView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/effect2" />
<ImageView
android:id="@+id/imageView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/effect3" />
<ImageView
android:id="@+id/imageView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/effect4" />
</LinearLayout>
</RelativeLayout>
**The ControlActivity:-**
package com.example.harsh.filters;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
public class ControlActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_control);
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.harsh.filters">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ControlActivity"
android:label="@string/title_activity_control"
android:theme="@style/AppTheme.NoActionBar"></activity>
</application>
</manifest>
请帮助我,谢谢。这看起来不错,你能在git上设置一个简单的测试项目让我看看吗?请发布你的日志