Turbolinks 5のAndroid開発とAndroidアダプターには非常に新しいです。私はウェブサイトをロードする小さなアプリケーションを書いていますが、リンクをクリックするとOKですが、電話機の戻るボタンを押してください。ページをナビゲートしてもリンクのいずれも機能せず、スワイプして更新することはできません。Turbolinks Androidアダプター - バックボタン
私が探し始める必要があるところのアイデアは歓迎されます。コードの引用にでも役に立つかわからない私はまだ行ったが、これは主ビットだと思いました。
public static Stack<String> intent_history = new Stack<String>();
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Find the custom TurbolinksView object in your layout
turbolinksView = (TurbolinksView) findViewById(R.id.turbolinks_view);
// For this demo app, we force debug logging on. You will only want to do
// this for debug builds of your app (it is off by default)
TurbolinksSession.getDefault(this).setDebugLoggingEnabled(true);
// For this example we set a default location, unless one is passed in through an intent
location = getIntent().getStringExtra(INTENT_URL) != null ? getIntent().getStringExtra(INTENT_URL) : BASE_URL;
// Execute the visit
TurbolinksSession.getDefault(this)
.activity(this)
.adapter(this)
.view(turbolinksView)
.visit(location);
}
public void visitProposedToLocationWithAction(String location, String action) {
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra(INTENT_URL, location);
intent_history.push(location); // Added to support UPDATE below
this.startActivity(intent);
}
UPDATE - onBackPressedメソッドをオーバーライドする必要がありました実現します。仕上げと出口が機能せず、また、私はそれが現在の画面をオフにポップするために二回裏にヒットする必要がありますが、それは大まかに動作し、私がする必要があるとき、私は洗練されます
@Override
public void onBackPressed() {
if (intent_history.isEmpty()) {
finish();
System.exit(0);
}
else {
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra(INTENT_URL, intent_history.pop());
this.startActivity(intent);
}
}
}
(ちょうど:私はのようなものを持っています現時点でのコンセプトのテスト)。
私はまったく同じ問題を抱えています。これで運がありましたか?私は私のレイアウトのためにブートストラップを使用していますが、これが関連している可能性がありますか? –
私は持っています。上記の訪問コールバックを使用して、私はその場所をスタックにプッシュしました...そして、バックボタンコールバックを使用して、私は最後の場所をポップし、それをアクティビティとして開始します。オフィスに戻ると、私は詳細を追加します。 – SimonKiteley