Lessondating ru golovin dating

Posted by / 25-Jan-2015 20:49

Lessondating ru

Further we will implement examples that will confirm this theory and everything will become more clear.In previous lessons we have learnt to invoke an Activity using Intent and explicitly defining the class.After this analogically create Action inside Intent Filter and write ru.startandroid.intent.action.showtime inside the Name field. But without this start Activity(Intent) invocation will not find an Activity. Let’s create such an Activity and name it Activity Date. That means that Intent with action = ru.startandroid.intent.action.showdate found and displayed Activity Date which fits it by Intent Filter. If you remember, in the Lesson №22 about Intent Filter, I wrote that one Intent can find several appropriate Activities.We also have to create Category inside the Intent Filter and in the name field choose android.intent.category. Create the layout for new Activity and name it time.xml: package ru.startandroid.develop.p0261intentfilter; import Actions are all the same as when creating Activity Time:- class creation- creating Activity in the manifest and creating an Intent Filter for it (with action = ru.startandroid.intent.action.showdate and category = android.intent.category. In this case the user will be given a choice which Activity to use. We will make one more Activity, which will react on Intent with action = ru.startandroid.intent.action.showdate.But we will implement this not by explicitly defining Activity classes in the Intent but using the Intent Filter. For example, there such system action-constants: ACTION_VIEW - view, ACTION_EDIT - edit, ACTION_PICK - selection from the list, ACTION_DIAL - make a call.Let’s create a project: Project name: P0261_Intent Filter Build Target: Android 2.3.3Application name: Intent Filter Package name: ru.startandroid.develop.p0261intentfilter Create Activity: Main Activity Open and draw two buttons:: package ru.startandroid.develop.p0261intentfilter; import If the action is performed on some data, then one more Intent-attribute is specified - data.Activity is created as usual - create Activity Time class which is the subclass of After it is registered in the manifest, we have to create an Intent Filter in the same place. Text View; public class Activity Time extends Activity Everything is simple here - calculate the current time and display it in the Text View. Let’s get back (Back button) and now press Show date button.To do so, select Activity Time, click Add, choose Intent Filter and click OK. The application will generate an error as it couldn’t find an Activity which corresponds to Intent with action = ru.startandroid.intent.action.showdate (we have created only for showtime). Text View; public class Activity Date extends Activity Save everything and run the application, press Show date and you will see date displayed.

Let’s have a look how is it implemented in practice. Inside on Click method we define which button has been clicked and create an Intent.

There may be an application installed that already uses showtime action - I don’t want to intercept with it.

That’s why my action is ru.startandroid.intent.action.showtime. So we have created an Intent with action and sent it to the system to look for Activities.

For Activity to fit for our intent it must contain an action attribute with the same value that action in the Intent.

It means we need to create two Activities, configure their Intent Filters and implement displaying date and time. That is Intent with action = ru.startandroid.intent.action.showtime found and displayed Activity, which has action which is equal to ru.startandroid.intent.action.showtime inside its Intent Filter.

lessondating ru-12lessondating ru-64lessondating ru-27

These topics are the basis - Task, Lifecycle, Intent.

One thought on “lessondating ru”