2014-04-24 6 views
6

Hallo Freunde, die ich eine App entwickle, ich eine Anforderung Benutzer musste umleiten Speicher von meiner Anwendung zu spielen, suchte ich eine Menge, aber keinen Erfolg .. Code untenRedirect Benutzerspeicher Wiedergabe Von Android App

ist
Button1.setOnClickListener(new OnClickListener() 
    { 
     @Override 
     public void onClick(View v_arg) { 
      try { 
         Intent viewIntent = 
         new Intent("android.intent.action.VIEW", 
         Uri.parse("https://play.google.com/store/apps/details?id=com.adeebhat.rabbitsvilla/")); 
         startActivity(viewIntent); 
      }catch(Exception e) { 
       Toast.makeText(getApplicationContext(),"Unable to Connect Try Again...", 
         Toast.LENGTH_LONG).show(); 
       e.printStackTrace(); 
      } 
     } 
    }); 

    Button2.setOnClickListener(new OnClickListener() 
    { 
     @Override 
     public void onClick(View v_arg) { 
      try { 
         Intent viewIntent = 
         new Intent("android.intent.action.VIEW", 
         Uri.parse("market://details?id=com.adeebhat.rabbitsvilla/")); 
         startActivity(viewIntent); 
      }catch(Exception e) { 
       Toast.makeText(getApplicationContext(),"Unable to Connect Try Again...", 
         Toast.LENGTH_LONG).show(); 
       e.printStackTrace(); 
      } 
     } 
    }); 
+1

Ihr Code scheint in Ordnung zu sein. Hast du einen Fehler? –

+0

mögliches Duplikat von [Wie öffne ich den Google Play Store direkt über meine Android-Anwendung?] (Http://stackoverflow.com/questions/11753000/how-to-open-the-google-play-store-directly-from- my-android-application) – TripeHound

Antwort

8

Entfernen Sie den Schrägstrich von der URL. Sie haben einen zusätzlichen Schrägstrich nach dem Paketnamen hinzugefügt.

https://play.google.com/store/apps/details?id=com.adeebhat.rabbitsvilla/ 

Es sollte

https://play.google.com/store/apps/details?id=com.adeebhat.rabbitsvilla 

Sowohl sein uri

Uri.parse("https://play.google.com/store/apps/details?id=com.adeebhat.rabbitsvilla")); // Removed slash 

und

Uri.parse("market://details?id=com.adeebhat.rabbitsvilla")); // Removed slash 
+0

Vielen Dank Freunde es war hilfreich –

+0

Ihre herzlichsten :) –

6

Sie müssen t gerade sein sollte o entfernen Charakter "/" aus der URL

So

https://play.google.com/store/apps/details?id=com.adeebhat.rabbitsvilla/ 

zu

https://play.google.com/store/apps/details?id=com.adeebhat.rabbitsvilla 

schließlich

Button1.setOnClickListener(new OnClickListener() 
{ 
    @Override 
    public void onClick(View v_arg) { 
     try { 
        Intent viewIntent = 
        new Intent("android.intent.action.VIEW", 
        Uri.parse("https://play.google.com/store/apps/details?id=com.adeebhat.rabbitsvilla")); 
        startActivity(viewIntent); 
     }catch(Exception e) { 
      Toast.makeText(getApplicationContext(),"Unable to Connect Try Again...", 
        Toast.LENGTH_LONG).show(); 
      e.printStackTrace(); 
     } 
    } 
}); 
+0

Vielen Dank Freunden es war hilfreich –

+1

Sie sind herzlich willkommen. – Piyush

11

Weiteren anspruchsvoller Art und Weise so sein wird:

final String appPackageName = getPackageName(); // package name of the app 
try { 
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); 
} catch (android.content.ActivityNotFoundException anfe) { 
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName))); 
} 
Verwandte Themen