我的基本應用程序有一個小問題。當我嘗試從列表(「IIMODULE」)開始第二個位置時,我的手機沒有任何反應。這裏的日誌來自LogCat:從菜單活動調用GPS活動
System.err(3416): java.lang.ClassNotFoundException: com.example.aplikacjatestowa.IIMODULE
我對這個錯誤的研究很少,但是我沒有發現任何特定的情況。任何人都可以看到我的錯誤?有任何想法嗎?
Menu類:
public class Menu extends ListActivity {
String[] mainMenuStrings = { "MAINACTIVITY", "IIMODULE", "III_Module",
"empty" };
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(Menu.this,
android.R.layout.simple_list_item_1, mainMenuStrings));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
String localSelector = mainMenuStrings[position];
Class ourClass;
try {
ourClass = Class.forName("com.example.aplikacjatestowa."
+ localSelector);
Intent ourIntent = new Intent(Menu.this, ourClass);
startActivity(ourIntent);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
我呼籲GPS例如新的活動:
public class GpsModule extends Activity {
public static Context cont;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.gps);
cont = getApplicationContext();
LocationManager locManager = (LocationManager) getSystemService(LOCATION_SERVICE);
LocationListener locListener = new MyLocationListener();
locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
locListener);
}
}
這裏是AndroidManifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.aplikacjatestowa"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Menu"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="com.example.aplikacjatestowa.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="com.example.aplikacjatestowa.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".GpsModule"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="com.example.aplikacjatestowa.IIMODULE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
任何應用程序你有一個名爲''IIMODULE''類在你的應用程序? – harism
omg ...我沒有解釋這種微不足道的錯誤 –