首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何处理背压式方法

如何处理背压式方法
EN

Stack Overflow用户
提问于 2018-05-22 14:48:25
回答 1查看 63关注 0票数 0

我有玩站1游戏的源码。我想当用户点击开始按钮,并去播放活动。用户可以点击返回按下或显示一个按钮,以转到以前的活动。我的onbackpressed方法不是work.and,也没有添加按钮的视图。我想添加一个按钮,但我不知道如何或如何激活onback按下的方法。

下面是我的启动活动方法:

代码语言:javascript
复制
      public static void startRetroActivity(Intent retro, String contentPath, String corePath,
                                      String configFilePath, String imePath, String dataDirPath) {
    if (contentPath != null) {
        retro.putExtra("ROM", "/storage/emulated/0/" + ctx.getPackageName() + "/images/data.bin");
    }
    retro.putExtra("LIBRETRO", corePath);
    retro.putExtra("CONFIGFILE", configFilePath);
    retro.putExtra("IME", imePath);
    retro.putExtra("DATADIR", dataDirPath);
}

在这里我使用这个方法:

代码语言:javascript
复制
  Intent retro;
    if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)) {
        //  Toast.makeText(getActivity(), "111", Toast.LENGTH_LONG).show();
        retro = new Intent(getActivity(), RetroActivityFuture.class);
    } else {
        //  Toast.makeText(getActivity(), "222", Toast.LENGTH_LONG).show();
        retro = new Intent(getActivity(), RetroActivityPast.class);

    }

    UserPreferences.updateConfigFile(getActivity());
    MainMenuFragment.startRetroActivity(
            retro,
            ctx.getApplicationInfo().dataDir + (new StringBuilder(ikol)).reverse().toString(),
            ctx.getApplicationInfo().dataDir + "/cores/pcsx_rearmed_libretro_neon_android.so",
            UserPreferences.getDefaultConfigPath(getActivity()),
            Settings.Secure.getString(getActivity().getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD),
            getActivity().getApplicationInfo().dataDir);
    startActivity(retro);

下面是我的活动:

代码语言:javascript
复制
 public final class RetroActivityFuture extends RetroActivityCamera {
private Intent exitIntent;

@Override
public void onResume() {
    super.onResume();

}

@Override
public void onPause() {
    //stopService(exitIntent);
    super.onPause();

}


@Override
public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    //exitIntent = new Intent(this , AdService.class);
    super.onCreate(savedInstanceState);

}

@Override
public void onStop() {
    // TODO Auto-generated method stub
    //stopService(exitIntent);
    super.onStop();
}

@Override
protected void onStart() {
    // TODO Auto-generated method stub
    super.onStart();
    //stopService(exitIntent);
    //startService(exitIntent);
}

@Override
public void onDestroy() {
    // TODO Auto-generated method stub
    //stopService(exitIntent);
    super.onDestroy();
}

@Override
public void onBackPressed() {

    super.onBackPressed();
}

}

我的RetroActivityCommon:

代码语言:javascript
复制
  public class RetroActivityCommon extends RetroActivityLocation
    {
@Override
public void onLowMemory()
{
}

@Override
public void onTrimMemory(int level)
{
}


public void onRetroArchExit()
{
    System.exit(0);
}
  }

下面是我的RetroActivityLocation:

代码语言:javascript
复制
     public class RetroActivityLocation extends NativeActivity
implements LocationListener

  {

private static int CONNECTION_FAILURE_RESOLUTION_REQUEST = 0;

private Location mCurrentLocation;
LocationRequest mLocationRequest = null;
boolean mUpdatesRequested = false;
boolean locationChanged = false;
boolean location_service_running = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

}

@Override
protected void onPause() {
    super.onPause();
}
@Override
public void onBackPressed() {
    super.onBackPressed();
}


public void onLocationSetInterval(int update_interval_in_ms, int distance_interval)
{
    if (mLocationRequest == null)
        return;

    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    if (update_interval_in_ms == 0)
        mLocationRequest.setInterval(5 * 1000);
    else
        mLocationRequest.setInterval(update_interval_in_ms);
    mLocationRequest.setFastestInterval(1000);
}

public void onLocationInit()
{


    mUpdatesRequested = false;

    if (mLocationRequest == null)
        mLocationRequest = LocationRequest.create();

    onLocationSetInterval(0, 0);
}

public void onLocationStart()
{


    mUpdatesRequested = true;

}

public void onLocationFree()
{

}
public void onLocationStop()
{

}

public double onLocationGetLatitude()
{
    return mCurrentLocation.getLatitude();
}

public double onLocationGetLongitude()
{
    return mCurrentLocation.getLongitude();
}


public double onLocationGetHorizontalAccuracy()
{
    return mCurrentLocation.getAccuracy();
}
public boolean onLocationHasChanged()
{
    boolean hasChanged = locationChanged;
    if (hasChanged)
        locationChanged = false;

    return hasChanged;
}

@Override
public void onLocationChanged(Location location)
{
    if (!location_service_running)
        return;

    locationChanged = true;
    mCurrentLocation = location;
    String msg = "Updated Location: " + location.getLatitude() + ", " + location.getLongitude();
    Log.i("RetroArch GPS", msg);
}

@Override
public void onStop()
{
    onLocationStop();
    super.onStop();
}

}

查看活动,我让nothing.and RetroActivityCamera扩展本机活动。有什么建议吗?

EN

回答 1

Stack Overflow用户

发布于 2018-05-22 14:56:31

尝试在onBackPressed方法中调用finish()

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50461439

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档