I want to open my app store link of my app on image click. On mainactivity file, inside the OnCreate, I have added following
ImageView Button = (ImageView)findViewById(R.id.imageView5);
Button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=APPNAME"));
startActivity(intent);
}
});
And on the layout file, here is my image;
<ImageView
android:id="@+id/imageView5"
android:layout_width="232dp"
android:layout_height="105dp"
android:layout_marginTop="10dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:visibility="visible"
ads:srcCompat="@drawable/write009" />
Where I am doing mistake ?
UPDATE: Here is what I got from the logcat after debug with virtual device
java.lang.RuntimeException: Unable to start activity
ComponentInfo{antivirus.android.APPNAME/com.APPNAME.activities.MainActivity}:
java.lang.NullPointerException: Attempt to invoke virtual method 'void
android.view.View.setOnClickListener(android.view.View$OnClickListener)' on a
null object reference