Intent receivedIntent = getIntent();
String receivedAction = receivedIntent.getAction();
//find out what we are dealing with
String receivedType = receivedIntent.getType();
String receivedText = receivedIntent.getStringExtra(Intent.EXTRA_TEXT);
if(receivedAction.equals(Intent.ACTION_SEND)){
mBodyText.setText(receivedText);
// activate share text
}
else
if(receivedAction.equals(Intent.ACTION_VIEW)){
Uri weblink = receivedIntent.getData();
try {
//22 siap
String urlink = weblink.getHost();
String urlinkpath = weblink.getPath();
//20 v13 asal
web.loadUrl("http://"+urlink +urlinkpath);
mTitleText.setText(""+urlink+urlinkpath);
String urlinkq = weblink.getQuery();
//22 tambah q not null. PENTING
if (urlinkq != null ){
web.loadUrl("http://"+urlink +urlinkpath+"?"+urlinkq);
mTitleText.setText(""+urlink+urlinkpath+"?"+urlinkq);
}
//23 tambah
String f = weblink.getFragment();
if (f != null ){
web.loadUrl("http://"+urlink +urlinkpath+"#"+f);
mTitleText.setText(""+urlink+urlinkpath+"#"+f);
}
//mesti ada. try catch
} catch (Exception e){
e.printStackTrace();
}
web.setWebViewClient(new WebViewClient());
Manifest tambah:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"/>
***aplikasi Screenshot Browser
https://play.google.com/store/apps/details?id=com.azharawang.browser
No comments:
Post a Comment