Some notes from Application Fundamentals
activities/intents
Activity.setContentView()
ContentResolver can talk to any ContentProvider
activities, services, and broadcast receivers are activated by asynchronous messages (intents)
Context.startActivity()
Activity.startActivityForResult() (we expect some result back, with onActivityResult())
intents are passed to activities by Android with onNewIntent()
starting service
Context.startService() (service's onStart() gets the intent)
Context.bindService() (to establish an ongoing connection, service's onBind() gets the intent)
initiating a broadcast
Context.sendBroadcast()
Context.sendOrderedBroadcast()
Context.sendStickyBroadcast()
shutting down components
no need to shutdown ContentProvider or BroadcastReceiver
shut down activity with finish(), or use finishActivity() to shut down the one it created
shut down service with stopSelf() method, or by calling Context.stopService()
declaring components
<activity>
<service>
<receiver> (BroadcastReceiver can be dynamically registered in code with Context.registerReceiver())
<provicer>
ex of activity declaration
<activity android:name="com.example.project.FreneticActivity"
android:icon="@drawable/small_pic.png"
android:label="@string/freneticLabel"
. . . >
ex of intent-filters declaration (inbetween a activity tag)
<intent-filter . . . > (entry point for the app)
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter . . . >
<action android:name="com.example.project.BOUNCE" />
<data android:mimeType="image/jpeg" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
principal Intent flags
FLAG_ACTIVITY_NEW_TASK
FLAG_ACTIVITY_CLEAR_TOP
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
FLAG_ACTIVITY_SINGLE_TOP
principal <activity> attributes
taskAffinity
launchMode
allowTaskReparenting
clearTaskOnLaunch
alwaysRetainTaskState
finishOnTaskLaunch
The affinity comes into play in two circumstances: When the Intent object that launches an activity contains the FLAG_ACTIVITY_NEW_TASK flag, and when an activity has its allowTaskReparenting attribute set to "true".
Four launch modes in <activity> element's launchMode attribute:
standard (the default mode, can appear anywhere in a stack)
singleTop can appear anywhere in a stack
singleTask will always be the root activity of the task
singleInstance (the only activity in its task)
Since I don't feel really well, I'll call it a day. By the way.. blogger editor is really f*cked. Next time I'll use HTML editing mode, I can't stand formatting issues it bugs me with.
No comments:
Post a Comment