2014-10-07 3 views
0

버튼을 클릭하여 인스 타 그램을 클릭하면 브라우저에서 직접 가져옵니다. 즉, 인스 트램 응용 프로그램으로 이동하고 싶습니다. 내 모바일, 브라우저에 가야한다. Instagram이 브라우저로 이동합니다

나는 둘 다 브라우저

에 직접 첫 번째 코드를 내게됩니다,이 시도 :

inslink.setOnClickListener(new OnClickListener() { 

@Override 
public void onClick(View arg0) { 

    try { 
    Uri uri = Uri.parse("http://instagram.com/natgeo"); 
    Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
    startActivity(intent); 
    } 

    catch (Exception e) { 
     Uri uri = Uri.parse("http://instagram.com/natgeo"); 
     Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
     startActivity(intent); 
    } 
    } 
}); 

두 번째 코드 :

inslink.setOnClickListener(new OnClickListener() { 

@Override 
public void onClick(View arg0) { 

    if (uri.contains("https://i.instagram.com/")) { 
    String natgeo = "natgeo"; 
     String uri = "instagram://Page/" + natgeo; 
     Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); 
     startActivity(intent); 

    } else { 
     String natgeo = "natgeo"; 
     String uri = "https://i.instagram.com/" + natgeo; 
     Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); 
     startActivity(i); 
      } 
    } 
}); 

답변

1

인스 타 그램 응용 프로그램 경로를 처리하지 않습니다 -prefix natgeo.

<activity android:name=".activity.UrlHandlerActivity" android:exported="true" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation|screenSize"> 
     <intent-filter> 
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <category android:name="android.intent.category.BROWSABLE" /> 
      <data android:scheme="http" android:host="instagr.am" android:pathPrefix="/p/" /> 
      <data android:scheme="https" android:host="instagr.am" android:pathPrefix="/p/" /> 
      <data android:scheme="http" android:host="instagram.com" android:pathPrefix="/p/" /> 
      <data android:scheme="https" android:host="instagram.com" android:pathPrefix="/p/" /> 
      <data android:scheme="http" android:host="instagram.com" android:pathPrefix="/_u/" /> 
      <data android:scheme="https" android:host="instagram.com" android:pathPrefix="/_u/" /> 
      <data android:scheme="http" android:host="instagram.com" android:pathPrefix="/_uid/" /> 
      <data android:scheme="https" android:host="instagram.com" android:pathPrefix="/_uid/" /> 
     </intent-filter> 
    </activity> 

그래서,이는 URL의 접두사 인스 타 그램 응용 프로그램 처리 :
http://instagr.am/p/
https://instagr.am/p/
http://instagram.com/p/
https://instagram.com/p/

읽기 XML 다음,이 인스 타 그램 응용 프로그램의 AndroidManifest.xml을 파일에서의 http://instagram.com/_u/
https://instagram.com/_u/
http://instagram.com/_uid/
https://instagram.com/_uid/

관련 문제