我有一个活动打开另一个活动,在此我无法使代码运行以在Android Studio中打开外部URL。 应用程序中断... 我使用了互联网许可。
代码:
public void onClick(View v){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("https://www.google.com.br"));
startActivity(intent);
}
我是否需要创建另一个JavaClass来输入这些代码,还是可以在MainActivity java中使用它?
logcat的
Process: br.com.vinnydantas.curriculo, PID: 3355 java.lang.IllegalStateException: Could not find method Linkedin(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.widget.ImageView with id 'imageLinkedin' at android.view.View$DeclaredOnClickListener.resolveMethod(View.java:4479) at android.view.View$DeclaredOnClickListener.onClick(View.java:4443) at android.view.View.performClick(View.java:5198) at android.view.View$PerformClick.run(View.java:21147) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
答案 0 :(得分:0)
你可以像这样打电话
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="myApp">
<div ng-controller="myCtrl">
{{name}} 123 {{name2}}
</div>
</body>