【发布时间】:2016-02-13 18:31:28
【问题描述】:
我正在尝试创建一个 android 应用程序,当它被点击时会打开一些 URL 地址。我知道有几个关于类似主题的问题,但我无法为此创建应用程序。尝试该应用程序后,出现了一些错误,因此我真的需要您的帮助。
在 AndroidManifest 中出现错误: - 无法解析符号“MainActivity”
在 XML AndroidManifest 中是这段代码:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="test222.intenrt2" >
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
在 MainActiviy 中出现错误: - 需要标识符
-无效的方法声明;需要返回类型
-缺少方法男孩或声明抽象
-未知类:'browserIntent'
-startAcitvity(browserIntent);
在 MainActivity.Java 中是这个
package test222.intenrt2;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.app.Application;
import android.test.ApplicationTestCase;
import android.content.Intent;
public class ApplicationTest extends ApplicationTestCase<Application> {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);
}
【问题讨论】: