如何启动的活动没有用户界面? [英] How to launch an Activity without a UI?
本文介绍了如何启动的活动没有用户界面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
时以任何可能的方式来启动从主功能的活动而无需用户界面?即是否有一种方式来创建一种包装周围的另一项活动,即通过开展的主要活动中,它会自动把你带到另一个活动。
如果这是不可能的,有没有办法从堆栈中删除的主要活动,使点击后退按钮不会带你到一个空白的用户界面? 这里是我想要做的一个例子:
公共类WrapperActivity延伸活动{
/ **第一次创建活动时调用。 * /
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
最终意向意图=新的意图(Intent.ACTION_DIAL,Uri.parse(电话:555-1212));
startActivity(意向);
}
}
解决方案
您需要添加的意图标志,
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
或
叫结束();
发射的意图后,
Is it in any way possible to launch an activity from the main function without having a UI? i.e. is there a way to create a sort of "wrapper" around another activity, i.e. by launching the main activity, it takes you to another activity automatically.
If that is not possible, is there a way to remove the main activity from the stack so that clicking the back button does not take you to a blank UI? Here's an example of what I'm trying to do:
public class WrapperActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:555-1212"));
startActivity(intent);
}
}
解决方案
You need to add the Intent flag,
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Or
call "finish();
" after firing the intent.
这篇关于如何启动的活动没有用户界面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文