11
我看了這個(How do I handle the browser's "share page" intent in android?),我可以通過Share鏈接來檢測我的應用程序,現在我該如何獲取Activity來接收URL?如何從瀏覽器收到「分享網址」?
找到答案:
Intent intent = getIntent();
if (savedInstanceState == null && intent != null) {
Log.d(TAG, "intent != null");
if (intent.getAction().equals(Intent.ACTION_SEND)) {
Log.d(TAG, "intent.getAction().equals(Intent.ACTION_SEND)");
String message = intent.getStringExtra(Intent.EXTRA_TEXT);
messageText.setText(message);
receiverText.requestFocus();
}
}
謝謝,這是我放在我的主要活動OnCreate中: 'Uri myI = getIntent()。getData(); String myItext = myI.toString(); mEditText.setText(myItext);' 但它強制關閉,一旦我嘗試將其轉換爲字符串(行#2) – James
@詹姆斯哦我的壞,當我回答這個問題時,我無法訪問模擬器/設備來測試它。我會建議使用額外的字符串,但你已經找到了答案。好工作 – Reno