android - 通过意图调用后如何清理和关闭应用程序
问题描述
我们有一个应用程序,它具有使用 Android 共享工具的功能。如果从 Rightmove 应用程序共享属性列表,我们的应用程序会获取该属性并将详细信息添加到我们的服务器端数据库。当应用程序正常启动(不是通过共享)时,它会在启动时检查更新。
该应用程序在正常启动时以及通过从 Rightmove 应用程序共享启动时执行它应该做的事情。除了后一种情况,它会继续检查不应该做的更新。
这是onCreate()
所有相关代码所在的方法:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Intent rightmove = getIntent();
String action = rightmove.getAction();
String type = rightmove.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
String rm_text = rightmove.getStringExtra(Intent.EXTRA_TEXT);
if (rm_text.startsWith("I found this property on the Rightmove")) {
String[] parts = rm_text.split("/");
String rm_code = parts[parts.length - 1];
new UpdateList().execute(rm_code);
} else {
Toast.makeText(this.getApplicationContext(), "Lets Delight only takes share information from the Rightmove app", Toast.LENGTH_LONG).show();
}
this.finish();
}
user = findViewById(R.id.user);
status = findViewById(R.id.status);
message = findViewById(R.id.message);
Button dman = findViewById(R.id.button_decision);
Button todo = findViewById(R.id.button_todo);
new Update(status).check(this);
}
if
处理共享的块结束,this.finish();
但代码在此之后继续并检查更新。因此,它必须绘制一个不需要或不使用的 UI。
这是一个finish();
需要一段时间才能完成的案例,并且在此过程中,代码会继续执行还是这里发生了其他事情?无论哪种方式,处理将共享信息发送到仅处理共享数据而不向用户呈现 UI 的应用程序的“正确”方式是什么?