0

当我使用这段代码时:

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com/"));
startActivity(browserIntent);

我收到这些错误消息:

08-26 18:14:35.305: E/AndroidRuntime(9427): FATAL EXCEPTION: main
08-26 18:14:35.305: E/AndroidRuntime(9427): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.browser/com.android.browser.BrowserActivity}: java.lang.RuntimeException: Parcelable encounteredClassNotFoundException reading a Serializable object (name = dev.socialnet.server.Server)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at android.os.Looper.loop(Looper.java:130)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at android.app.ActivityThread.main(ActivityThread.java:3691)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at java.lang.reflect.Method.invokeNative(Native Method)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at java.lang.reflect.Method.invoke(Method.java:507)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at dalvik.system.NativeStart.main(Native Method)
08-26 18:14:35.305: E/AndroidRuntime(9427): Caused by: java.lang.RuntimeException: Parcelable encounteredClassNotFoundException reading a Serializable object (name = dev.socialnet.server.Server)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at android.os.Parcel.readSerializable(Parcel.java:2026)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at android.os.Parcel.readValue(Parcel.java:1897)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at android.os.Parcel.readMapInternal(Parcel.java:2083)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at android.os.Bundle.unparcel(Bundle.java:208)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at android.os.Bundle.getBundle(Bundle.java:1078)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at android.content.Intent.getBundleExtra(Intent.java:3843)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at com.android.browser.BrowserActivity.handleWebSearchIntent(BrowserActivity.java:1463)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at com.android.browser.BrowserActivity.onCreate(BrowserActivity.java:488)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
08-26 18:14:35.305: E/AndroidRuntime(9427):     ... 11 more
08-26 18:14:35.305: E/AndroidRuntime(9427): Caused by: java.lang.ClassNotFoundException: dev.socialnet.server.Server
08-26 18:14:35.305: E/AndroidRuntime(9427):     at java.lang.Class.classForName(Native Method)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at java.lang.Class.forName(Class.java:234)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:2564)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at java.io.ObjectInputStream.readNewClassDesc(ObjectInputStream.java:1823)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:811)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2039)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:916)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2262)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2217)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at android.os.Parcel.readSerializable(Parcel.java:2020)
08-26 18:14:35.305: E/AndroidRuntime(9427):     ... 20 more
08-26 18:14:35.305: E/AndroidRuntime(9427): Caused by: java.lang.NoClassDefFoundError: dev.socialnet.server.Server
08-26 18:14:35.305: E/AndroidRuntime(9427):     ... 30 more
08-26 18:14:35.305: E/AndroidRuntime(9427): Caused by: java.lang.ClassNotFoundException: dev.socialnet.server.Server in loader dalvik.system.PathClassLoader[/system/framework/twframework.jar:/system/framework/sec_feature.jar:/system/framework/sechardware.jar:/system/app/Browser.apk]
08-26 18:14:35.305: E/AndroidRuntime(9427):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
08-26 18:14:35.305: E/AndroidRuntime(9427):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-26 18:14:35.305: E/AndroidRuntime(9427):     ... 30 more
4

3 回答 3

0

我觉得 AndroidManifest.xml 中缺少您的活动,如下所示:

<activity
            android:name="dev.socialnet.server.Server"
            android:label="@string/app_name">

        </activity>
于 2012-08-26T16:27:04.957 回答
0

我设法通过从意图中删除包含类名的额外内容来解决问题。就我而言,它是“clazz=com.example.ExampleActivity”。为了删除额外的内容,我在我的活动的 startActivity 方法中执行了此操作。

@Override
public void startActivity( final Intent intent, final Bundle options )
{
    intent.removeExtra( "clazz" );
    super.startActivity( intent, options );
}

仅供参考:我在通过覆盖 WebViewClient 的 shouldOverrideUrlLoading 从 Web 视图打开链接(mailto 和 http)时遇到了问题。

希望这对某人有所帮助(花了我大约 2.5 小时才找到解决方案)。

于 2013-03-18T13:06:51.827 回答
0

试试这个。

final Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url));
activity.startActivity(intent);

或者..

Uri uriUrl = Uri.parse("http://www.google.com/");   
Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl);
startActivity(launchBrowser);
于 2012-08-26T16:22:37.523 回答