2014-09-14 2 views
0

사용자가 Google 재생 음악 버튼을 클릭하면 Google 재생 음악이 열리는 앱 작업 ​​중입니다. 그러나 앱을 닫았다가 다시 열면 Google이 실행됩니다. 음악 재생 애플 리케이션이 아니에요. 내 앱 화면으로 돌아 가기 위해 뒤로 버튼을 클릭해야합니다. 좋은 사용자 경험이 아닙니다! 그래서 내가 어떻게 해결 할이 여기 내 코드입니다 :안드로이드 클래스의 인 텐트 인스턴스의 단일 인스턴스를 수행하는 방법

import android.app.Activity; 
import android.content.ComponentName; 
import android.content.Intent; 
import android.net.Uri; 
import android.os.Bundle; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.view.View; 

public class QuickLaunch extends Activity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_quick_launch); 
    } 

    /** Called when the user clicks the music button */ 
    public void music(View view) { 
     Intent intent = new Intent("android.intent.action.MUSIC_PLAYER"); 
     startActivity(intent); 
    } 



/** Called when the user clicks the play button */ 
public void play(View view) { 
    Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.android.vending"); 
    startActivity(launchIntent); 
    } 



/** Called when the user clicks the web button */ 
public void web(View view) { 
    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://google.com/")); 
     startActivity(browserIntent); 
} 

     /** Called when the user clicks the email button */ 
public void email(View view) { 
    Intent intent = getPackageManager().getLaunchIntentForPackage("com.android.email"); 
    startActivity(intent); 

} 

/** Called when the user clicks the sms button */ 
public void chat(View view) { 
    Intent intent = new Intent(Intent.ACTION_MAIN); 
intent.setComponent(new ComponentName("com.d4a.sms","de.ub0r.android.smsdroid.ConversationListActivity")); 
intent.putExtra("grace", "Hi"); 
startActivity(intent); 
} 


/** Called when the user clicks the settings button */ 
public void settings(View view) { 
    Intent intent = getPackageManager().getLaunchIntentForPackage("com.android.settings"); 
    startActivity(intent); 

} 



/** Called when the user clicks the camera button */ 
public void cam(View view) { 
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); 
    startActivityForResult(intent, 0); 

} 

/** Called when the user clicks the video camara button */ 
public void video_cam(View view) { 
    Intent intent = new Intent("android.media.action.VIDEO_CAPTURE"); 
    startActivityForResult(intent, 0); 

} 
} 

나는 구글이 음악을 연주 시작 사용하고 어떤 코드를 알고 코드에서 음악을 재생 조각에서 찾아보세요. 수정 당신이 안드로이드 활동이 줄을 추가해야 매니페스트 쉬웠다 링크를 제공

+0

이것은 예상되는 동작입니다. 앱 재개시 일반적으로 가장 최근에 연 활동 (이 경우 Google Play 뮤직 활동)으로 계속 진행됩니다. –

+0

그래서 그것을 고치는 방법이 있습니까 ?? – appd3vs

+0

내가 그것을 이해했던 링크에 감사드립니다! – appd3vs

답변

0

감사 코드 - 견습생 :

android:launchMode="singleInstance" 

나는이 내 신발에 있던 사람을 도움이 될 수 있습니다 희망!

관련 문제