1. Are you ready for the Galaxy S20? Here is everything we know so far!

Instagram error

Discussion in 'Android Development' started by SamoZain, Oct 6, 2014.

  1. SamoZain

    SamoZain Newbie
    Thread Starter

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

    Code (Text):
    1. package com.example.a;
    2.  import android.app.Activity;
    3.  import android.content.Intent;
    4.  import android.net.Uri;
    5.  import android.os.Bundle;
    6.  import android.widget.Button;
    7.  import android.view.View;
    8.  import android.view.View.OnClickListener;
    9.  public class MainActivity extends Activity {
    10.  Button dadclink;
    11.  @Override
    12.  public void onCreate(Bundle savedInstanceState) {
    13.  super.onCreate(savedInstanceState);
    14.  setContentView(R.layout.activity_main);
    15.  addListenerOnButton();
    16.  }
    17.  public void addListenerOnButton() {
    18.  dadclink = (Button) findViewById(R.id.dadclink);
    19.  
    20.  dadclink.setOnClickListener(new OnClickListener() {
    21.  @Override
    22.  public static Intent newInstagramProfileIntent(PackageManager pm, String url) {
    23.  Intent intent = new Intent(Intent.ACTION_VIEW);                 try {
    24.  if (pm.getPackageInfo("com.instagram.android", 0) != null) {
    25.  if (url.endsWith("/")) {
    26.  url = url.substring(0, url.length() - 1);
    27.  }
    28.  String natgeo = url.substring(url.lastIndexOf("/") + 1);
    29.  intent.setData(Uri.parse("http://instagram.com/_u/" + natgeo));
    30.  intent.setPackage("com.instagram.android");
    31.  return intent;
    32.  }
    33.  } catch (NameNotFoundException e) {
    34.  }
    35.  intent.setData(Uri.parse(url));
    36.  return intent;
    37.  }}
    38.  }
    39.  };
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...

Share This Page

Loading...