Udacity – czego nauczyłam się z kursu cz.6

1)Services

https://developer.android.com/guide/components/services.html

  • Jak wystartować service
Intent myIntent=new Intent(this,MyIntentSErvice.class);

myIntent.setAction(„some action”);

startService(myIntent);

2) Klasa service

 

public class MyIntentService extends IntentService {

@Override

Protected void onHandleIntent(Intent intent)

{

//do background work here

String action=intent.getAction();

}

}

3) Liczba mnoga w łańcuchach znaków

 

https://developer.android.com/guide/topics/resources/string-resource.html#Plurals

In the strings.xml file for the Hydration Reminder app, you’ll see an example of how pluralization can be used:

 

<plurals name="charge_notification_count">

   <item quantity="zero">Hydrate while charging reminder sent %d times</item>

   <item quantity="one">Hydrate while charging reminder sent %d time</item>

   <item quantity="other">Hydrate while charging reminder sent %d times</item>

</plurals>

When you use the plural in code, you specify a quantity number. This number specifies what string should be used. In this case:

  • if the number is zero, use <item quantity=”zero”>
  • If the number is one, use <item quantity=”one”>
  • otherwise use <item quantity=”other”>

Then in the MainActivity we have the following Java code to generate the correct String:

 

String formattedChargingReminders = getResources().getQuantityString(R.plurals.charge_notification_count, chargingReminders, chargingReminders);

 

The first usage of chargingReminder is the quantity number. It determines which version of the pluralized string to use (you must pass in a number). The second usage of chargingReminder is the number that’s actually inserted into the formatted string.

4) Deklaracja service w pliku manifest.xml

<service android:name=".sync.WaterReminderIntentService"
 android:exported="false" ></service>

5) kanał Android Develpers na youtube:

https://www.youtube.com/channel/UCVHFbqXqoYvEWM1Ddxl0QDg

6) Powiadomienia

https://developer.android.com/guide/topics/ui/notifiers/notifications.html

https://developer.android.com/training/notify-user/build-notification.html

7) PendingIntent

https://developer.android.com/reference/android/app/PendingIntent.html

8) Uprawnienia w pliku andrdoidmanifest.xml do wibracji w telefonie

<uses-permission android:name="android.permission.VIBRATE"></uses-permission>

Dodaj komentarz

Twój adres email nie zostanie opublikowany. Pola, których wypełnienie jest wymagane, są oznaczone symbolem *