gpt4 book ai didi

android - 如何在按下后停止 android Mx Player

转载 作者:行者123 更新时间:2023-11-30 03:01:46 25 4
gpt4 key购买 nike

我有一个代码,当我第一次启动应用程序时它可以通过 mx 播放器显示视频,但没有任何错误,但是如果我关闭并再次打开应用程序,它说 Activity mx 播放器没有响应。我如何关闭 mx 播放器当我按后退按钮。我的代码:

公共(public)类 MainActivity 扩展 Activity {

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

startMxPlayer(1, 1);
finish();
}


private void startMxPlayer(int tuner, int ch) {
int port = 8000 + tuner * 10 + ch;
Uri uri = Uri.parse("udp://224.1." + (port & 0xff) + ".1:" + port);
Log.v("server", "udp://224.1." + (port & 0xff) + ".1:" + port);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setPackage( "com.mxtech.videoplayer.ad" );
intent.putExtra("end_by","user");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY);
getApplication().startActivity(intent);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

最佳答案

没有人可以停止终止进程,但我建议您以其他方式进行。

private void startMxPlayer(int tuner, int ch) { 
int port = 8000 + tuner * 10 + ch;
Uri uri = Uri.parse("udp://224.1." + (port & 0xff) + ".1:" + port);
Log.v("server", "udp://224.1." + (port & 0xff) + ".1:" + port);

// add the following line.
ActivityManager.killBackgroundProcesses("com.mxtech.videoplayer.ad");

Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setPackage( "com.mxtech.videoplayer.ad" );
intent.putExtra("end_by","user");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY);
getApplication().startActivity(intent);

关于android - 如何在按下后停止 android Mx Player,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22408413/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com