Android Programming Tutorials

(Romina) #1
Now, Your Friends Are Alarmed

i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|
Intent.FLAG_ACTIVITY_SINGLE_TOP);


PendingIntent pi=PendingIntent.getActivity(this, 0 ,
i,
0 );


note.setLatestEventInfo(this, "Identi.ca Post!",
"Found your keyword: "+NOTIFY_KEYWORD,
pi);


mgr.notify(NOTIFICATION_ID, note);
}


BroadcastReceiver onBatteryChanged=new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
int pct= 100
*intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 1 )
/intent.getIntExtra(BatteryManager.EXTRA_SCALE, 1 );


isBatteryLow.set(pct<= 25 );
}
};


class Account {
String user=null;
String password=null;
IPostListener callback=null;


Account(String user, String password,
IPostListener callback) {
this.user=user;
this.password=password;
this.callback=callback;
}
}


public class LocalBinder extends Binder implements IPostMonitor {
public void registerAccount(String user, String password,
IPostListener callback) {
Account l=new Account(user, password, callback);


poll(l);
accounts.put(callback, l);
}


public void removeAccount(IPostListener callback) {
accounts.remove(callback);
}
}
}


297
Free download pdf