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



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

myIntent.setAction(„some action”);


2) Klasa service


public class MyIntentService extends IntentService {


Protected void onHandleIntent(Intent intent)


//do background work here

String action=intent.getAction();



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



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>


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:


6) Powiadomienia



7) PendingIntent


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

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

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany.