Presentation on theme: "Cosc 5/4730 Permissions. Note that all of start with android.premission. Location: – ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION, ACCESS_LOCATION_EXTRA_COMMANDS,"— Presentation transcript:
Other Misc Permissions ADD_VOICEMAIL – Added in API level 14, app must have access to a voicemail server. – Constant Value: "com.android.voicemail.permission.ADD_VOICEMAIL" DISABLE_KEYGUARD, EXPAND_STATUS_BAR FLASHLIGHT, GET_PACKAGE_SIZE KILL_BACKGROUND_PROCESSES – Added in API level 8 – Allows an application to call killBackgroundProcesses(String)
Other permissions. I skipped over all the “system” permissions. – Says, “Not for use by third-party applications.” in the documentation. You app must be a system level app, which you can’t do without rooting your phone or becoming a vendor, like say Motorola. – http://stackoverflow.com/questions/14256687/ho w-to-make-my-application-system http://stackoverflow.com/questions/14256687/ho w-to-make-my-application-system
Calendar Example Once a calendar is connected to the device You can use the following example from google to read/write to the calendar – Uses the Calendar Provider http://developer.android.com/guide/topics/pr oviders/calendar-provider.html http://developer.android.com/guide/topics/pr oviders/calendar-provider.html
Contacts Example Same with contacts http://developer.android.com/guide/topics/pr oviders/contacts-provider.html http://developer.android.com/guide/topics/pr oviders/contacts-provider.html
User Dictionary Android use the user dictionary for the example in the “content provider basics” example. http://developer.android.com/guide/topics/pr oviders/content-provider-basics.html http://developer.android.com/guide/topics/pr oviders/content-provider-basics.html
AccountManager Provides a centralized registry of the user online accounts – Example: Facebook, dropbox, Evernote, etc… – There are some examples of how to use and create your “account” for your online service. http://www.finalconcept.com.au/article/view/android- account-manager-step-by-step http://www.finalconcept.com.au/article/view/android- account-manager-step-by-step http://developer.android.com/reference/android/accou nts/AccountManager.html http://developer.android.com/reference/android/accou nts/AccountManager.html
Incoming/outgoing phone calls Detectcalls app in PremissionDemo.zip Uses: PROCESS_OUTGOING_CALLS and READ_PHONE_STATE The example uses two Broadcast Receivers – You can do it in one, but split for the example. – Able to get the phone number and the information. – http://androidlabs.org/short-experiments/broadcast- receivers/process-outgoing-calls/ http://androidlabs.org/short-experiments/broadcast- receivers/process-outgoing-calls/ This example also shows you have to change the incoming phone number! – http://code.google.com/p/krvarma-android- samples/source/browse/trunk/DetectCalls/?r=37 http://code.google.com/p/krvarma-android- samples/source/browse/trunk/DetectCalls/?r=37
Incoming/outgoing phone calls (2) You can block outgoing phone calls – You use: setResultData(null); – That will stop the outbound call! http://stackoverflow.com/questions/599443/hang-up- outgoing-call-in-android http://stackoverflow.com/questions/599443/hang-up- outgoing-call-in-android – You can not drop/ignore incoming calls thought. Requires the MODIFY_PHONE_STATE permission, which is a system level permission. http://stackoverflow.com/questions/15012082/rejecting- incoming-call-in-android http://stackoverflow.com/questions/15012082/rejecting- incoming-call-in-android http://androidsourcecode.blogspot.in/2010/10/blocking- incoming-call-android.html http://androidsourcecode.blogspot.in/2010/10/blocking- incoming-call-android.html
Task lists RunningApp in the Demo shows how to get the Running Applications. – It’s pretty simple. – Get the ActivityManager from the service – You can get RunningServices, RunningAppProcesses, RunningTasks, and RecentTasks. My example will list the package name for each one in the list. Reference: http://stackoverflow.com/questions/5446565/android- how-do-i-check-if-activity-is-running http://stackoverflow.com/questions/5446565/android- how-do-i-check-if-activity-is-running
Reorder Tasks(2) While facebook, use the reorder_tasks permission, I can’t find a single example for it. What I did find an interesting article on how all the activities (tasks) work on the back to front of the stack. – And managing how your activities are launched with the launch modes.
WallPaper Get the intance of the wallpaper manager. Then use setBitmap, setResource, or setStream methods to change the wallpaper The example (setwallpaper) is very simple and uses a wallpaper in the resource directory.
Read/Write profile In JellyBean (Api 14+) you can have several user profiles. – And we have methods to read and write these profiles. – It’s handled through the Contracts, so you will need at least READ_CONTACTS permission as well and READ_PROFILE and WRITE_PROFILE
Read/Write profile The profile is handled with a ContentProvider. So to get the entire profile (I think every profile) you need the following query: Cursor c = getContentResolver().query( ContactsContract.Profile.CONTENT_URI, null, null, null, null);
Read profile example The readPofile project reads all the profiles on the device and displays the information to the screen, using the query before. Remember the device must be 14+ to use this one. My example is heavy modified, but based on http://android- codelabs.appspot.com/resources/tutorials/conta ctsprovider/ex1.html http://android- codelabs.appspot.com/resources/tutorials/conta ctsprovider/ex1.html