關注these instructions。您需要先安裝eclipse。您必須啓動eclipse android應用程序,然後才能運行應用程序。用火線連接服務器的USB電纜。
雖然開始你需要調用應用程序,adb shell am start -n com.amazon.sample.helloworld.MainActivity
對於完整的工作Mainactivity看看下面的代碼,
package com.example.firetv;
import android.support.v7.app.ActionBarActivity;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebSettings.PluginState;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
public class Init extends ActionBarActivity {
WebView web;
private static boolean sFactoryInit = false;
private WebSettings webSettings;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_init);
web = (WebView) findViewById(R.id.myWebView);
webSettings = web.getSettings();
webSettings.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
webSettings.setBuiltInZoomControls(true);
web.getSettings().setPluginState(PluginState.ON);
web = new WebView(this);
web.getSettings().setJavaScriptEnabled(true); // enable javascript
web.setWebChromeClient(new WebChromeClient() {
});
final Activity activity = this;
web.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(activity, description, Toast.LENGTH_SHORT).show();
}
});
web.clearCache(true);
web.loadUrl("http://server.com/firetv/out/");
setContentView(web);
web.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
web.loadUrl("http://google.com");
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.init, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
「如何在這種情況下遠程的行爲?」 - 不好,我想象。 「我需要改變我的佈局嗎?」 - 很可能,是的。 「如果是這樣怎麼樣?」 - 它需要通過鍵盤才能使用,因爲Fire TV遙控器會爲D-pad和其他按鈕發送按鍵事件。這對於輔助功能也是必需的,因此視覺和運動不佳的用戶可以使用輔助技術來幫助導航您的應用。 – CommonsWare
@CommonsWare嗨,所以你會認爲,通過遵循這些準則,我可以讓我的應用程序亞馬遜火災準備:http://developer.android.com/training/keyboard-input/navigation.html? – Androidicus
是的,雖然標籤導航部分不相關。定向導航部分將映射到Fire TV遙控器的功能。如果您不想在Fire TV上持續測試,則使用常規Android設備的仿真器或藍牙鍵盤是測試鍵盤輸入的好方法。 – CommonsWare