오늘 Google Play 서비스 서비스를 최신 버전의 앱으로 업데이트했습니다. 이클립스는 나에게 어떤 종류의 오류도주지 않고있다. 나는 그것을 컴파일했다. 그리고 나는 나의 휴대 전화에서 테스트 할 때 잘 동작한다. 그런 다음 메뉴로 가서 종료를 선택하고 예를 선택하여 닫으면 앱이 화면에서 사라진다. 그러나 휴대 전화 하단에있는 사각형을 누르면 (열어 놓은 모든 앱을 나열 할 때) 앱이 계속 실행 중입니다! o_O앱을 종료 한 후에도 앱이 열려 있습니까? 뭐가 잘못 되었 니?
업데이트하기 전에 앱이 정상적으로 종료되었으며 종료 한 후에도 활성 상태로 유지됩니다. 하지만 GPS가 이런 종류의 문제를 일으킬 수 있다고 생각하지 않습니다. 어떠한 제안???
여기
package com.myapp.radio;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.IBinder;
import android.view.Menu;
import android.view.MenuItem;
import com.myapp.radio.R;
public class BaseActivity extends Activity {
private Intent bindIntent;
private RadioService radioService;
private static boolean isExitMenuClicked;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
isExitMenuClicked = false;
// Bind to the service
bindIntent = new Intent(this, RadioService.class);
bindService(bindIntent, radioConnection, Context.BIND_AUTO_CREATE);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
@Override
protected void onResume() {
super.onResume();
if (isExitMenuClicked == true)
finish();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_menu, menu);
if (radioService.getTotalStationNumber() <= 1) {
}
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intent i;
final String thisClassName = this.getClass().getName();
final String thisPackageName = this.getPackageName();
if (item.getItemId() == R.id.radio) {
if (!thisClassName.equals(thisPackageName + ".MainActivity")) {
i = new Intent(this, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
return true;
}
} else if (item.getItemId() == R.id.exit) {
String title = "Cerrar aplicación";
String message = "¿Realmente desea salir?";
String buttonYesString = "Si";
String buttonNoString = "No";
isExitMenuClicked = true;
AlertDialog.Builder ad = new AlertDialog.Builder(this);
ad.setTitle(title);
ad.setMessage(message);
ad.setCancelable(true);
ad.setPositiveButton(buttonYesString,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (radioService != null) {
radioService.exitNotification();
radioService.stop();
radioService.stopService(bindIntent);
isExitMenuClicked = true;
finish();
}
}
});
ad.setNegativeButton(buttonNoString, null);
ad.show();
return true;
} else if (item.getItemId() == R.id.about) {
if (!thisClassName.equals(thisPackageName + ".AboutActivity")) {
i = new Intent(this, AboutActivity.class);
startActivity(i);
return true;
}
} else if (item.getItemId() == R.id.facebook) {
if (!thisClassName.equals(thisPackageName + ".FacebookActivity")) {
i = new Intent(this, FacebookActivity.class);
startActivity(i);
return true;
}
} else if (item.getItemId() == R.id.twitter) {
if (!thisClassName.equals(thisPackageName + ".TwitterActivity")) {
i = new Intent(this, TwitterActivity.class);
startActivity(i);
return true;
}
}
return super.onOptionsItemSelected(item);
}
// Handles the connection between the service and activity
private final ServiceConnection radioConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
radioService = ((RadioService.RadioBinder) service).getService();
}
@Override
public void onServiceDisconnected(ComponentName className) {
radioService = null;
}
};
protected void onCreate1(Bundle savedInstanceState) {
// TODO Auto-generated method stub
}
}
Android의 일반적인 동작입니다. 운영 체제는 앱을 닫은 후에도 메모리에 앱을 보관하도록 선택할 수 있습니다. 다양한 기기와 Android 버전이 이와 관련하여 다른 행동을 보일 수 있습니다. –
Typo, MainActivity가 실제로 BaseActivity.java 인 것을 의미 할 때 – unarea
@ScottKronheim은 그것을 없애고 닫는 방법이 있습니까? 사용자가 휴대 전화에서 앱을 닫을 수있는 유일한 방법은 실행중인 프로세스를 확인하고 억류를 강요하거나 사각형을 누른 다음 앱의 오른쪽 상단 모서리에있는 X를 클릭하는 것입니다. – unarea