使用Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.xx.yyyy");
if (LaunchIntent != null) {
startActivity(LaunchIntent);
finish();
}
调用其他应用的意图后,我无法重定向活动。
假设我有一个“ A”应用和“ B”应用。
在应用程序“ A”中,A1是我的活动启动器。从A1导航到A2活动,并调用应用程序“ B”的意图
我的问题是,在活动B中完成某些任务后,想返回到应用“ A”,为什么它总是转到活动“ A1”而不是“ A2”,而应用“ B”的意图是从。我希望它返回到呼叫者意图而不是第一意图。
有人知道诀窍吗?
我的代码如下所示:
def index
@leave = Leave.new # as you have added it, won't affect what we want to achieve.
#if params have status then only you've to show
#the selected ones otherwise you'll be showing all
#of them. right?
if params[:status].present?
@leaves = Leave.where(status: params[:status])
#dont use find_by it will return only one record instead of array.
else
@leaves = Leave.includes(:user).order(created_at: :desc)
end
end
<%= form_tag(url: admin_leaves_path, method: :get) do %>
<div class="input-group">
#Leave.approved will hit database from view. which is not recommended
#instead of that try using values which will be accessed in controller
#via params and then you can perform actions according to it.
<%= select_tag :status, options_for_select([['Approved', true], ['Pending', false]]) %>
<%= submit_tag 'Filter' %>
</div>
<% end %>
请帮助我解决问题,非常感谢您的帮助。
答案 0 :(得分:1)
因为您正在完成活动A2:
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.xx.yyyy");
if (LaunchIntent != null) {
startActivity(LaunchIntent);
finish(); // HERE... You are finishing A2
}
只需删除finish();