我正在开发Android应用程序,在我的应用程序中,我想通过单击UHFMenuActivity中的布局来打开UHFMainActivity,但应用程序正在崩溃。当我使用另一个活动而不是UHFMenuActivity时它完全正常。我认为UHFMenuActivity存在问题。
这是我的UHFMenuActivity代码......
public class UHFMenuActivity extends Activity {
LinearLayout layoutAdd, layoutScan, layoutReport, layoutList;
ImageView imageScan;
Button btnNext;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(R.layout.custom_action_bar);
layoutAdd = (LinearLayout)findViewById(R.id.layoutAdd);
layoutScan = (LinearLayout)findViewById(R.id.layoutScan);
layoutReport = (LinearLayout)findViewById(R.id.layoutReport);
layoutList = (LinearLayout)findViewById(R.id.layoutList);
imageScan = (ImageView)findViewById(R.id.imageScan);
layoutAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(UHFMenuActivity.this, AddStudentActivity.class);
startActivity(intent);
}
});
layoutScan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(UHFMenuActivity.this, UHFMainActivity.class);
startActivity(intent);
}
});
layoutReport.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(UHFMenuActivity.this, ViewReportActivity.class);
startActivity(intent);
}
});
layoutList.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(UHFMenuActivity.this, ListStudentActivity.class);
startActivity(intent);
}
});
}
}
activity_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="110dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Student Attendance"
android:textStyle="bold"
android:gravity="center"
android:textSize="30sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_weight="5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_weight="5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/layoutAdd">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:src="@drawable/add" />
</LinearLayout>
<LinearLayout
android:layout_weight="5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/layoutScan">
<ImageView
android:id="@+id/imageScan"
android:layout_width="120dp"
android:layout_height="120dp"
android:src="@drawable/scan" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_weight="5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_weight="5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/layoutReport">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:src="@drawable/report" />
</LinearLayout>
<LinearLayout
android:layout_weight="5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/layoutList">
<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:src="@drawable/list1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
AndroidManifest.xml代码。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.uhf"
android:versionCode="1"
android:versionName="1.0"
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="15" />
<application
android:allowBackup="true"
android:icon="@drawable/logo_thsti_trans"
android:label="AsseTrack"
android:theme="@style/CustomTheme">
<activity
android:name="com.example.uhf.activity.UHFMenuActivity"
android:windowSoftInputMode="stateAlwaysHidden"
android:screenOrientation="portrait"
android:label="@string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activity.UHFMainActivity"
android:windowSoftInputMode="stateAlwaysHidden"/>
</application>
</manifest>
这是我的日志错误。
06-15 11:26:36.831 4308-4328/com.example.uhf E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.example.uhf, PID: 4308
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load DeviceAPI from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.uhf-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.uhf-1, /vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:526)
at com.rscja.deviceapi.DeviceAPI.<clinit>(DeviceAPI.java:1459)
at com.rscja.deviceapi.RFIDWithUHF.getDeviceAPI(RFIDWithUHF.java:41)
at com.rscja.deviceapi.RFIDWithUHF.init(RFIDWithUHF.java:214)
at com.example.uhf.activity.BaseTabFragmentActivity$InitTask.doInBackground(BaseTabFragmentActivity.java:179)
at com.example.uhf.activity.BaseTabFragmentActivity$InitTask.doInBackground(BaseTabFragmentActivity.java:173)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
06-15 11:26:37.458 4308-4340/com.example.uhf E/ContentValues: Couldn't get json from server.
06-15 11:26:37.494 4308-4340/com.example.uhf E/ContentValues: Couldn't get json from server.
06-15 11:26:37.534 656-689/? E/InputDispatcher: channel '42467078 com.example.uhf/com.example.uhf.activity.UHFMainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
06-15 11:26:37.534 656-689/? E/InputDispatcher: channel '4247b2d8 com.example.uhf/com.example.uhf.activity.UHFMainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!