嗨,我是 android 新手,我创建了 2 个项目。
现在,我想通过单击按钮从第一个项目中调用第二个项目中的活动。
第一个项目仅处理登录屏幕,当我单击登录按钮时,我需要调用第二个项目中存在的活动。
我搜索了网络,但没有找到任何我理解正确的教程。
嗨,我发现了以下错误。
01-30 08:36:47.230: E/dalvikvm(3408): Could not find class 'com.androidhive.googleplacesandmaps.MainActivity', referenced from method org.fluturasymphony.recommendation.LoginActivity$DownloadWebPageTask.doInBackground
01-30 08:36:52.587: E/AndroidRuntime(3408): FATAL EXCEPTION: AsyncTask #1
01-30 08:36:52.587: E/AndroidRuntime(3408): java.lang.RuntimeException: An error occured while executing doInBackground()
01-30 08:36:52.587: E/AndroidRuntime(3408): at android.os.AsyncTask$3.done(AsyncTask.java:299)
01-30 08:36:52.587: E/AndroidRuntime(3408): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
01-30 08:36:52.587: E/AndroidRuntime(3408): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
01-30 08:36:52.587: E/AndroidRuntime(3408): at java.util.concurrent.FutureTask.run(FutureTask.java:239)
01-30 08:36:52.587: E/AndroidRuntime(3408): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
01-30 08:36:52.587: E/AndroidRuntime(3408): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
01-30 08:36:52.587: E/AndroidRuntime(3408): at java.lang.Thread.run(Thread.java:856)
01-30 08:36:52.587: E/AndroidRuntime(3408): Caused by: java.lang.NoClassDefFoundError: com.androidhive.googleplacesandmaps.MainActivity
01-30 08:36:52.587: E/AndroidRuntime(3408): at org.fluturasymphony.recommendation.LoginActivity$DownloadWebPageTask.doInBackground(LoginActivity.java:69)
01-30 08:36:52.587: E/AndroidRuntime(3408): at org.fluturasymphony.recommendation.LoginActivity$DownloadWebPageTask.doInBackground(LoginActivity.java:1)
01-30 08:36:52.587: E/AndroidRuntime(3408): at android.os.AsyncTask$2.call(AsyncTask.java:287)
01-30 08:36:52.587: E/AndroidRuntime(3408): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
01-30 08:36:52.587: E/AndroidRuntime(3408): ... 3 more
我已将清单声明为这样。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fluturasymphony.recommendation"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="9"
android:targetSdkVersion="11" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name">
<activity android:label="@string/app_name" android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="org.achartengine.GraphicalActivity" />
<activity android:name=".CategoryWiseSalesChartActivity" />
<activity android:name=".ProductWiseSalesChartActivity" />
<activity android:name="com.androidhive.googleplacesandmaps.MainActivity"/>
<activity android:label="@string/home_screen" android:name=".HomeActivity" android:configChanges="orientation">
</activity>
<activity android:label="@string/store_screen" android:name=".StoreActivity" android:configChanges="orientation">
</activity>
<activity android:label="@string/store_list_screen" android:name=".StoreListActivity" android:configChanges="orientation">
</activity>
<activity android:label="@string/location_screen" android:name=".StoreMapActivity" android:configChanges="orientation">
</activity>
<activity android:label="@string/recommended_products_list_screen" android:name=".RecommendedProductsListActivity" android:configChanges="orientation">
</activity>
<activity android:label="@string/category_wise_sales_screen" android:name=".CategoryWiseSalesActivity" android:configChanges="orientation">
</activity>
<activity android:label="@string/product_wise_sales_screen" android:name=".ProductWiseSalesActivity" android:configChanges="orientation">
</activity>
<uses-library android:name="com.google.android.maps" />
</application>
</manifest>
我正在像这样调用第二堂课的活动。
Intent loginintent = new Intent("com.androidhive.googleplacesandmaps.MainActivity");
startActivity(loginintent);
这是正确的吗??