アンドロイド:ランチャーを作成する方法
-
25-09-2019 - |
質問
私は、Android用に開発されたことがありません:)
私は、与えられたURLにデフォルトのWebブラウザを開きますアプリケーションランチャを作成したいと思います。 言い換えれば、私は私のウェブサイトのロゴとアイコンを作りたい、とあなたがそれをクリックすると、それはデフォルトのWebブラウザでサイトを開きます。
誰かがこれを達成するためのチュートリアル/ドキュメントページに向けて私を指示してもらえますか? それは本当に簡単かどうか、多分ここに私にいくつかのコードを表示?
あなたの時間をありがとう!
P
解決
、あなただけのただ1活性を持つシンプルなアプリを作成してのonCreateでこれを固執ことができます:
Intent viewIntent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.yourwebsite.com"));
startActivity(viewIntent);
そして、ここでは簡単なアプリを作成するには、いくつかのリソースです
ここでとは、あなたのアプリのアイコンを設定する方法についていくつかの情報があります:
他のヒント
私はこのためのチュートリアルを書きました:= D
ます。http: //www.anddev.org/code-snippets-for-android-f33/button-to-open-web-browser-t48534.htmlする
バージョンを変更
package com.blundell.twitterlink;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sendToTwitter(); // Open the browser
finish(); // Close this launcher app
}
protected void sendToTwitter() {
String url = "http://twitter.com/blundell_apps"; // You could have this at the top of the class as a constant, or pass it in as a method variable, if you wish to send to multiple websites
Intent i = new Intent(Intent.ACTION_VIEW); // Create a new intent - stating you want to 'view something'
i.setData(Uri.parse(url)); // Add the url data (allowing android to realise you want to open the browser)
startActivity(i); // Go go go!
}
}
1行の答え
startActivity(new Intent("android.intent.action.VIEW", Uri.parse(url)));
なぜあなたはこれを行うためのアプリケーションを作成したいですか?あなたは自分のホーム画面に直接ショートカットを作成することができます。
はここで何をするかです:
お使いのブラウザでウェブサイトに移動します
2.
サイト(メニュー、ブックマークを追加)のブックマークを追加します。
あなたがロゴをしたいホーム画面に移動します。3.
4.を押して、画面を保持し、メニューがポップアップ表示さ
「ショートカットを追加」を選択します
5. [ブックマーク]
6.作成したばかりのブックマークを見つけ、それをクリックしてください。
あなたが終わっ!!