• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Instagram error

SamoZain

Newbie
I took this code but I think I'm messing ) .. I tried it at the end but still an error, does anybody know?

Code:
package com.example.a;
 import android.app.Activity;
 import android.content.Intent;
 import android.net.Uri;
 import android.os.Bundle;
 import android.widget.Button;
 import android.view.View;
 import android.view.View.OnClickListener;
 public class MainActivity extends Activity {
 Button dadclink;
 @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 addListenerOnButton();
 }
 public void addListenerOnButton() {
 dadclink = (Button) findViewById(R.id.dadclink);

 dadclink.setOnClickListener(new OnClickListener() {
 @Override
 public static Intent newInstagramProfileIntent(PackageManager pm, String url) {
 Intent intent = new Intent(Intent.ACTION_VIEW);                 try {
 if (pm.getPackageInfo("com.instagram.android", 0) != null) {
 if (url.endsWith("/")) {
 url = url.substring(0, url.length() - 1);
 }
 String natgeo = url.substring(url.lastIndexOf("/") + 1);
 intent.setData(Uri.parse("http://instagram.com/_u/" + natgeo));
 intent.setPackage("com.instagram.android");
 return intent;
 }
 } catch (NameNotFoundException e) {
 }
 intent.setData(Uri.parse(url));
 return intent;
 }}
 }
 };
 
Back
Top Bottom