Download Intent Filters - Florida State University

Document related concepts
no text concepts found
Transcript
Mobile
Programming
Lecture 5
Composite Views, Activities,
Intents and Filters
Lecture 4 Review
● How do you get the value of a string in the
strings.xml file?
● What are the steps to populate a Spinner or
ListView using XML?
● How many Android application components are there?
Name one.
● How do you launch an Activity B from within Activity A?
Agenda
● More on ListView
● ViewFlipper
● TabLayout
● Activity LifeCycle
● Configuration Changes
● URI
● Intent Filters
ListView - subitems
lv = (ListView) findViewById(R.id. listView1);
String[] names = new String[]{ "Leon Brown" ,"John Doe" ,"Leeroy Jenkins" };
String[] addresses = new String[]{ "Tallahassee, FL" , "Atlanta, Georgia" , "New York, NY" };
List<Map<String,String>> data =
new ArrayList<Map<String,String>>();
HashMap<String, String> map;
for (int i = 0; i < names.length; i++) {
map = new HashMap<String, String>();
map.put( "name", names[i]);
map.put( "address" , addresses[i]);
data.add(map);
}
SimpleAdapter adapter = new SimpleAdapter( this, data, android.R.layout. simple_list_item_2,
new String[] { "name", "address" }, new int[] { android.R.id. text1,
android.R.id. text2 });
lv.setAdapter(adapter);
ViewFlipper
Click here to view Flipper!
ViewFlipper
Sorry about that ...
ViewFlipper
● A ViewFlipper allows you to switch
between views that are children of the
ViewFlipper
● You can find it in the Expert menu in
Graphical Layout
ViewFlipper
<ViewFlipper
android:id="@+id/myViewFlipper"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
</RelativeLayout>
</ViewFlipper>
ViewFlipper
<ViewFlipper
android:id="@+id/myViewFlipper"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
</ViewFlipper>
Here I used
RelativeLayouts, but you
can place any widget you
want in here.
ViewFlipper
<ViewFlipper
android:id="@+id/myViewFlipper"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent”>
</RelativeLayout>
</ViewFlipper>
Here I also used just 2
Views. You can add more
than just 2 Views if you
want to.
ViewFlipper
ViewFlipper flipper;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
flipper = (ViewFlipper) findViewById(R.id.viewFlipper1);
flipper.setFlipInterval(500);
flipper.startFlipping();
}
ViewFlipper
ViewFlipper flipper;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
flipper = (ViewFlipper) findViewById(R.id.viewFlipper1);
flipper.setFlipInterval(500);
flipper.startFlipping();
}
Here we set the flipper to
flip every 500 milliseconds
ViewFlipper
ViewFlipper flipper;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Here we set the flipper to
flip when the flipper is
clicked
flipper.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
flipper.showNext();
}
});
}
FrameLayout
● FrameLayout is designed to block out an
area on the screen to display a single item
● FrameLayout should be used to hold a
single child View
○ It can be difficult to organize child Views in a w
that's scalable to different screen sizes withou
children overlapping each other
TabLayout
Wraps multiple Views into a single window
● Navigate through the Views using tabs
NOTE - TabActivity was deprecated in API Level 13,
Fragments should be used instead
TabLayout - Anatomy
ACTIVITY
TABHOST
●
TABWIDGET
●
FRAMELAYOUT
TAB CONTENT
●
TabHost
○ Container holding TabWidget
and a FrameLayout
TabWidget
○ Row of tab buttons
FrameLayout
○ Container holding the tab
contents
○ each tab content is a child of
FrameLayout
TabLayout - XML
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
ACTIVITY
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
TABHOST
android:layout_height="fill_parent">
<LinearLayout
TABWIDGET
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
</TabHost>
FRAMELAYOUT
TAB CONTENT
TabLayout - XML
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
ACTIVITY
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
TABHOST
android:layout_height="fill_parent">
<LinearLayout
TABWIDGET
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
FRAMELAYOUT
TAB CONTENT
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
</TabHost>
Tabs are different Activities,
we set specify the layout for
each tab programmatically
TabLayout
● If you're going to have x tabs, create x
Activities, 1 for each tab in addition to the
TabActivity on the next slide
● You can create x XML layouts for each tab,
or you can reuse the same layout for each
tab.
TabLayout
public class TabLayoutExampleActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super .onCreate(savedInstanceState);
setContentView(R.layout. main);
TabHost tabHost = getTabHost();
// The activity TabHost
TabHost.TabSpec spec;
Intent intent = new Intent(TabLayoutExampleActivity. this,
LinearLayout.class);
spec = tabHost.newTabSpec( "linear layout" ).setIndicator( "Linear" ,
null).setContent(intent);
tabHost.addTab(spec);
intent = new Intent(TabLayoutExampleActivity. this, TableLayout.class);
spec = tabHost.newTabSpec( "table layout" ).setIndicator( "Table",
null).setContent(intent);
tabHost.addTab(spec);
}
TabLayout
extend TabActivity
public class TabLayoutExampleActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = getTabHost();
// The activity TabHost
TabHost.TabSpec spec;
Intent intent = new Intent(TabLayoutExampleActivity.this, LinearLayout.class);
spec = tabHost.newTabSpec("linear layout").setIndicator("Linear",
null).setContent(intent);
tabHost.addTab(spec);
intent = new Intent(TabLayoutExampleActivity.this, TableLayout.class);
spec = tabHost.newTabSpec("table
layout").setIndicator("Table",null).setContent(intent);
tabHost.addTab(spec);
}
TabLayout
public class TabLayoutExampleActivity extends TabActivity {
@Override
public void
the XML file containing the
TabHost, TabWidget,
onCreate(Bundle
savedInstanceState) {
FrameLayout
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = getTabHost();
// The activity TabHost
TabHost.TabSpec spec;
Intent intent = new Intent(TabLayoutExampleActivity.this, LinearLayout.class);
spec = tabHost.newTabSpec("linear layout").setIndicator("Linear",
null).setContent(intent);
tabHost.addTab(spec);
intent = new Intent(TabLayoutExampleActivity.this, TableLayout.class);
spec = tabHost.newTabSpec("table
layout").setIndicator("Table",null).setContent(intent);
tabHost.addTab(spec);
}
TabLayout
public class TabLayoutExampleActivity extends TabActivity {
@Override
public void onCreate(Bundle
savedInstanceState)
Reference
to the Activity's{
super.onCreate(savedInstanceState);
TabHost (which was
defined in XML)
setContentView(R.layout.main);
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent = new Intent(TabLayoutExampleActivity.this, LinearLayout.class);
spec = tabHost.newTabSpec("linear layout").setIndicator("Linear",
null).setContent(intent);
tabHost.addTab(spec);
intent = new Intent(TabLayoutExampleActivity.this, TableLayout.class);
spec = tabHost.newTabSpec("table layout").setIndicator("Table",
null).setContent(intent);
tabHost.addTab(spec);
}
TabLayout
public class TabLayoutExampleActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Reusable TabSpec for
setContentView(R.layout.main);
each Tab.
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent = new Intent(TabLayoutExampleActivity.this, LinearLayout.class);
spec = tabHost.newTabSpec("linear layout").setIndicator("Linear",
null).setContent(intent);
tabHost.addTab(spec);
intent = new Intent(TabLayoutExampleActivity.this, TableLayout.class);
spec = tabHost.newTabSpec("table layout").setIndicator("Table",
null).setContent(intent);
tabHost.addTab(spec);
}
TabLayout
public class TabLayoutExampleActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
The TabSpec tells the TabHost
super.onCreate(savedInstanceState);
what views represent the
tab contents and what the tab
buttons should look like.
setContentView(R.layout.main);
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent = new Intent(TabLayoutExampleActivity.this, LinearLayout.class);
spec = tabHost.newTabSpec("linear layout").setIndicator("Linear",
null).setContent(intent);
tabHost.addTab(spec);
intent = new Intent(TabLayoutExampleActivity.this, TableLayout.class);
spec = tabHost.newTabSpec("table
layout").setIndicator("Table",null).setContent(intent);
tabHost.addTab(spec);
}
TabLayout
public class TabLayoutExampleActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Remember from the previous
lecture, this is how we use an
TabHost tabHost = getTabHost();
Intent object to start another
TabHost.TabSpec
spec;
Activity
Intent intent = new Intent(TabLayoutExampleActivity.this, LinearLayout.class);
spec = tabHost.newTabSpec("linear layout").setIndicator("Linear",
null).setContent(intent);
tabHost.addTab(spec);
Intent intent = new Intent(TabLayoutExampleActivity.this, TableLayout.class);
spec = tabHost.newTabSpec("table layout").setIndicator("Table",
null).setContent(intent);
tabHost.addTab(spec);
}
TabLayout
public class TabLayoutExampleActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = getTabHost();
TabHost.TabSpec
Refer to thisspec;
TabActivity's
tab host (which will contain
theintent
actual =tabs)
Intent
new Intent(TabLayoutExampleActivity.this,
LinearLayout.class);
spec = tabHost.newTabSpec("linear layout").setIndicator("Linear",
null).setContent(intent);
tabHost.addTab(spec);
Intent intent = new Intent(TabLayoutExampleActivity.this, TableLayout.class);
spec = tabHost.newTabSpec("table layout").setIndicator("Table",
null).setContent(intent);
tabHost.addTab(spec);
}
TabLayout
public class TabLayoutExampleActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Create a new tab spec,
give it the id "linear layout"
Intent intent = new Intent(TabLayoutExampleActivity.this, LinearLayout.class);
spec = tabHost. newTabSpec("linear layout").setIndicator("Linear",
null).setContent(intent);
tabHost.addTab(spec);
Intent intent = new Intent(TabLayoutExampleActivity.this, TableLayout.class);
spec = tabHost.newTabSpec("table layout").setIndicator("Table",
null).setContent(intent);
tabHost.addTab(spec);
}
TabLayout
public class TabLayoutExampleActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = getTabHost();
Set the label for the tab
(label the user sees) to
"Linear". And
Intent(TabLayoutExampleActivity.this, LinearLayout.class);
TabHost.TabSpec spec;
Intent intent = new
spec = tabHost.newTabSpec("linear layout"). setIndicator("Linear",
null).setContent(intent);
tabHost.addTab(spec);
Intent intent = new Intent(TabLayoutExampleActivity.this, TableLayout.class);
spec = tabHost.newTabSpec("table layout").setIndicator("Table",
null).setContent(intent);
tabHost.addTab(spec);
}
TabLayout
public class TabLayoutExampleActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
We're not using an image
Intent
= new
Intent(TabLayoutExampleActivity.this,
forintent
the tabs,
so null
for this
argument
LinearLayout.class);
spec = tabHost.newTabSpec("linear layout").setIndicator("Linear" ,
null).setContent(intent);
tabHost.addTab(spec);
Intent intent = new Intent(TabLayoutExampleActivity.this, TableLayout.class);
spec = tabHost.newTabSpec("table layout").setIndicator("Table",
null).setContent(intent);
tabHost.addTab(spec);
}
TabLayout
public class TabLayoutExampleActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent =
Fill the FrameLayout to
holdIntent(TabLayoutExampleActivity.this,
the Activity specified
new
by this intent
LinearLayout.class);
spec = tabHost.newTabSpec("linear layout").setIndicator("Linear" ,
null).setContent(intent);
tabHost.addTab(spec);
Intent intent = new Intent(TabLayoutExampleActivity.this, TableLayout.class);
spec = tabHost.newTabSpec("table layout").setIndicator("Table",
null).setContent(intent);
tabHost.addTab(spec);
}
TabLayout
public class TabLayoutExampleActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent = new Intent(TabLayoutExampleActivity.this, LinearLayout.class);
spec
Add the tab to the tabHost,
it will now show up in the
=
UItabHost.newTabSpec("linear
layout").setIndicator("Linear" ,
null).setContent(intent);
tabHost.addTab(spec);
Intent intent = new Intent(TabLayoutExampleActivity.this, TableLayout.class);
spec = tabHost.newTabSpec("table layout").setIndicator("Table",
null).setContent(intent);
tabHost.addTab(spec);
}
TabLayout
public class TabLayoutExampleActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent = new Intent(TabLayoutExampleActivity.this, LinearLayout.class);
spec
= tabHost.newTabSpec("linear
layout").setIndicator("Linear" ,
To add
another tab, let's
do this all
over again!
null).setContent(intent);
tabHost.addTab(spec);
Intent intent = new Intent(TabLayoutExampleActivity.this, TableLayout.class);
spec = tabHost.newTabSpec("table layout").setIndicator("Table",
null).setContent(intent);
tabHost.addTab(spec);
}
TabLayout - Rules
●
TabHost must have the id
@android:id/tabhost
●
The TabWidget must have the id
@android:id/tabs
●
The FrameLayout must have the id —
@android:id/tabcontent
TabHost - useful methods
● setCurrentTab(int)
○ Make this tab the active tab, making it visible in the UI
● setOnTabChangedListener(OnTabChangedListener)
○ React to when the active tab changes
Activity LifeCycle
Here's a nice picture of the Activity LifeCycle
Activity LifeCycle - onCreate()
● Called when the Activity is first created.
● This is where you should do all of your normal static
setup: create views, bind data to lists, etc.
● Provides you with a Bundle containing the Activity's
previously frozen state, if there was one.
● Always followed by onStart().
Activity LifeCycle - onStart()
● Called when the Activity is becoming visible to the user
● Followed by
○ onResume() if the Activity comes to the foreground
○ onStop() if it becomes hidden.
Activity LifeCycle - onRestart()
● Called after your Activity has been stopped, prior to it
being started again
● Always followed by onStart()
Activity LifeCycle - onResume()
● Called when the Activity will start interacting with the
user
● At this point your Activity is at the top of the Activity
stack, with user input going to it
● Always followed by onPause()
Activity LifeCycle - onPause()
●
●
●
●
Called when the system is about to start resuming a previous Activity
This is typically used to commit unsaved changes to persistent data, stop
animations and other things that may be consuming CPU, etc
Implementations of this method must be very quick because the next
Activity will not be resumed until this method returns
Followed by
○ onResume() if the Activity returns back to the front
○ onStop() if it becomes invisible to the user.
Activity LifeCycle - onStop()
● Called when the Activity is no longer visible to the user
because another Activity has been resumed and is covering
this one
● This may happen either because a new Activity is being
started, an existing one is being brought in front of this one,
or this one is being destroyed
● Followed by
○ onRestart() if this Activity is coming back to interact
with the user
○ onDestroy() if this Activity is going away
Activity LifeCycle - onDestroy()
● The final call you receive before your Activity is
destroyed
● This can happen either because
○
The Activity is finishing (someone called finish()
on it)
○
The system is temporarily destroying this instance of
the Activity to save space
● You can distinguish between these two scenarios with
the isFinishing() method
Activity LifeCycle
There are three key loops you may be interested in monitoring within your
Activity:
●
Entire lifetime
○
●
Visible lifetime
○
●
Between the first call to onCreate() through to a single final call to
onDestroy()
between a call to onStart() until a corresponding call to onStop()
Foreground lifetime
○
between a call to onResume() until a corresponding call to
onPause()
Configuration Changes
● You can detect when the configuration of the
device changes
●
○ screen orientation, keyboard availability, and
language
The system will try to handle the changes for you,
unless you specify that you want to handle them
yourself
Configuration Changes - Manifest
● To specify that you want to handle orientation and
●
keyboard availability changes yourself
Open the manifest file and add the bold line
<activity
android:configChanges="orientation|keyboardHidden"
android:name=".OnConfigurationChangedExampleActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Configuration Changes - Manifest
● This will prevent the restarts when the orientation
changes and when keyboard availability changes
<activity
android:configChanges="orientation|keyboardHidden"
android:name=".OnConfigurationChangedExampleActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Configuration Changes - Event
Then, to react to the orientation change event, add this
method to your Activity
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation ==
Configuration.ORIENTATION_LANDSCAPE) {
/* ... */
}
else if (newConfig.orientation ==
Configuration.ORIENTATION_PORTRAIT) {
/* ... */
}
}
Passing Data between Activities
When you start Activity B from Activity A, you
may want to send data to Activity B
Activity A
Activity B
startActivity B
send some data to B also
Passing Data between Activities
Activity A onCreate()
Activity B onCreate()
Intent intent = new Intent(this,
Intent intent = getIntent();
SecondActivity.class);
Bundle bundle = intent.getExtras();
Bundle bundle = new Bundle();
if (bundle != null) {
bundle.putString( "fname", "John");
bundle.putString( "lname", "Doe");
edit1.setText(bundle.getString
(
"fname"));
bundle.putInt( "age", 18);
edit2.setText(bundle.getString
(
intent.putExtras(bundle);
"lname"));
int age= bundle.getInt( "age");
startActivity(intent);
}
URIs
● Uniform Resource Identifier
● An abstract or physical resource, as specified by RFC
2396
● A URI is composed of many parts
● This class can both parse URI strings into parts and
compose URI strings from parts
URIs
● A URI is composed of many parts
● But there are 4 main parts to a URI
○ Scheme
○ Port
○ Host
○ Path
URIs - Examples - Hierarchical
http://mobile.cs.fsu.edu/android
http://twitter.com
file:///tmp/android.txt
scheme
host
port
path
http
mobile.cs.fsu.edu
80
android
http
twitter.com
file
/tmp/android.txt
URIs - Examples - Opaque
mailto:robots.example.com
scheme
scheme-specific part
mailto
robots.example.com
URIs - Parsing URIs
URI uri = Uri.parse("http://www.google.com");
String scheme = uri.getScheme();
String host = uri.getHost();
int port = uri.getPort();
String path = uri.getPath();
String schemeSpecificPart =
uri.getSchemeSpecificPart();
Intent Filters
To inform the system which implicit Intents
they can handle, Activities, Services, and
Broadcast Receivers can have one or more
IntentFilters
● Each filter describes a capability of the component, a
●
set of Intents that the component is willing to receive
It filters in Intents of a desired type, while filtering out
unwanted Intents — but only unwanted implicit
Intents (those that don't name a target class)
Intent Filters
● Explicit Intent
○ Always delivered to its target, no matter what i
contains; the filter is not consulted
● Implicit Intent
○ Delivered to a component only if it can pass th
one of the component's filters
Intent Filters
We have seen this before!
new Intent(A.this, B.class)
● Explicit Intent
○ Always delivered to its target, no matter what it
contains; the filter is not consulted
● Implicit Intent
○ Delivered to a component only if it can pass through
one of the component's filters
Intent Filters
● How does Android know that you may want
to open the YouTube app when you try to
watch a video on YouTube?
● Using Intent Filters
● We will create an app that can be used to
launch links at
○
http://mobile.cs.fsu.edu
Intent Filters
<activity
android:name=".MyActivity"
android:label="@string/app_name" >
<intent-filter>
<data
android:scheme="http"
android:host="mobile.cs.fsu.edu" />
<action android:name="android.intent.action.VIEW" />
<category
android:name="android.intent.category.DEFAULT"/>
<category
android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
Intent Filters
<activity
android:name=".MyActivity"
android:label="@string/app_name" >
<intent-filter>
<data
android:scheme="http"
android:host="mobile.cs.fsu.edu" />
<action android:name="android.intent.action.VIEW" />
<category
android:name="android.intent.category.DEFAULT"/>
<category
android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
Intent Filters
<activity
android:name=".MyActivity"
android:label="@string/app_name" >
<intent-filter>
<data
android:scheme="http"
android:host="mobile.cs.fsu.edu" />
<action android:name="android.intent.action.VIEW" />
<category
android:name="android.intent.category.DEFAULT"/>
<category
android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
Intent Filters
<activity
android:name=".MyActivity"
android:label="@string/app_name" >
<intent-filter>
<data
android:scheme="http"
Display data to the user.
Generic action you can use on
a piece of data to get the most
reasonable thing to occur
android:host="mobile.cs.fsu.edu" />
<action android:name="android.intent.action.VIEW" />
<category
android:name="android.intent.category.DEFAULT"/>
<category
android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
Intent Filters
<activity
android:name=".MyActivity"
android:label="@string/app_name" >
<intent-filter>
<data
android:scheme="http"
Set if the Activity should be an
android:host="mobile.cs.fsu.edu" option
/> for the default action on a
piece of data.
<action android:name="android.intent.action.VIEW" />
<category
android:name="android.intent.category.DEFAULT"/>
<category
android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
Intent Filters
<activity
android:name=".MyActivity"
android:label="@string/app_name" >
<intent-filter>
<data
android:scheme="http"
android:host="mobile.cs.fsu.edu" />
Activities that can be safely
<action android:name="android.intent.action.VIEW"
/> must
invoked from a browser
support this category. It's
<category
required here.
android:name="android.intent.category.DEFAULT"/>
<category
android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
Intent Filters
<activity
This is an Implicit
Intent!
android:name=".MyActivity"
android:label="@string/app_name" >
<intent-filter>
<data
android:scheme="http"
android:host="mobile.cs.fsu.edu" />
<action android:name="android.intent.action.VIEW" />
<category
android:name="android.intent.category.DEFAULT"/>
<category
android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
References
● The Busy Coder's Guide to Android
Development - Mark Murphy
● Android Developers
● The Mobile Lab at Florida State University
Related documents