Android Application Development Cookbook: 93 Recipes for Building Winning Apps



Download 32,34 Mb.
Pdf ko'rish
bet38/56
Sana26.02.2022
Hajmi32,34 Mb.
#470540
1   ...   34   35   36   37   38   39   40   41   ...   56
Bog'liq
Android Application Development Cookbook

Android Versions
Level 1 and above
permissions
android.permission.INTERNET
source code to download at Wrox.com
IntentFilters.zip
In all the previous recipes you have launched other apps by using the 
Intent
object. What about 
your own apps? How do you allow other apps to call yours using the 
Intent
object? This recipe 
shows you how. 
solution
Assume you have the following class in your application:
package net.learn2develop.intentfilters;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MyBrowserActivity extends Activity { 
@Override
public void onCreate(Bundle savedInstanceState) 

super.onCreate(savedInstanceState); 
setContentView(R.layout.browser);
Uri url = getIntent().getData();
WebView webView = (WebView) findViewById(R.id.webView); 
webView.setWebViewClient(new Callback()); 
if (url!=null) {
webView.loadUrl(url.toString());
} else {
webView.loadUrl("http://www.google.com");
}
}
www.it-ebooks.info


 
Recipe 1.8 Making Your Application callable By others

33
private class Callback extends WebViewClient { 
@Override
public boolean shouldOverrideUrlLoading( 
WebView view, String url) {
return(false);
}

}
Basically, the preceding class loads an XML file named 
browser.xml
(shown next) that contains a 
WebView
. It displays a web page based on the data passed in through the 
Intent
object: 
 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
android:id="@+id/webView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

The class is also declared in your 
AndroidManifest.xml
file as follows:
package="net.learn2develop.intentfilters"
android:versionCode="1"
android:versionName="1.0" >
android:minSdkVersion="8"
android:targetSdkVersion="15" />

android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:name=".MainActivity"
android:label="@string/title_activity_main" >





www.it-ebooks.info



Download 32,34 Mb.

Do'stlaringiz bilan baham:
1   ...   34   35   36   37   38   39   40   41   ...   56




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish