【发布时间】:2012-01-01 02:02:31
【问题描述】:
我有一个启动另一个类似这样的活动的启动活动
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
final Thread splashThread = new Thread() {
@Override
public void run() {
try {
int wait = 0;
while (_isActive && (_splashTime > wait)) {
sleep(100);
if (_isActive) {
wait += 100;
}
}
} catch (InterruptedException e) {
Log.d(TAG, e.getMessage());
} finally {
startActivity(new Intent("com.path1.path2.SomeActivity"));
finish();
}
}
};
splashThread.start();
}
要开始另一个活动,我使用Intent 构造函数的字符串参数。相应的类与这样的启动字符串配对
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.path1.path2"
android:versionCode="2"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="4"/>
<!--permissions-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application android:label="@string/app_name" android:icon="@drawable/icon">
<activity android:name=".SplashActivity"
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=".SomeActivity"
android:label="@string/app_name"
>
<intent-filter>
<action android:name="com.path1.path2.SomeActivity"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name=".OtherActivity" android:label="@string/app_name"
/>
<!--services-->
<service android:name=".AlarmService"/>
</application>
</manifest>
在我重命名包名称之前,这可以完美运行。我通过使用重构重命名清单中的包名称,IDE 相应地重命名所有其他类。但是当我想开始新重命名的项目时,我遇到了一个错误
Launching application: com.path1.pathOLD/com.path1.path2.SplashActivity.
DEVICE SHELL COMMAND: am start -n "com.path1.pathOLD/com.path1.path2.SplashActivity"
Starting: Intent { cmp=com.path1.pathOLD/com.path1.path2.SplashActivity }
Error type 3
Error: Activity class {com.path1.pathOLD/com.path1.path2.SplashActivity} does not exist.
似乎该应用程序尝试使用 OLDpath/NEWpath.Splash 路径启动 Splash 活动并且错误在那里,但我找不到它为什么使用这样的路径。
我使用 IntelliJ IDE。有任何想法吗?会不会在 Manifest 的第二个活动的过滤器中?!
【问题讨论】:
-
那么,你的问题解决了吗?
-
请到休闲聊天室,我们可以在那里讨论您的问题。
-
好的,只需在清单文件中更改包名称,写入“com.path1.pathOLD”并再次运行您的应用程序,让我知道发生了什么......
标签: android intellij-idea android-intent intentfilter