I want to show a ListView with the events of the current day from a specific calendar. The calendar is originally fetched from a .ical file and synchronized into my google account. And yes, I've searched.
Should I go with the content:// stuff?
Im using Android 2.2 and above.
One option would be to use the Google Calendar API functions. On the surface it seems like tons of work, however you are mostly importing (Build Path) their jar files and making the appropriate imports and method calls.
http://code.google.com/apis/calendar/v3/getting_started.html
This turns into HTTP requests and the like, which implies you must always be connected to the network (I'm not a fan of that).
Officially supported or not, I am working on an application that is working with the local phone calendar database and doing what I need to do there (yes, the content:// URI stuff you mentioned above).
Either way, you can do what you are needing to do as your application seems simple enough. Most people, and rightfully so, will tell you to use the Google Calendar API imports/calls because it is supported functionality that does not rely on how the device manufacturer chose to implement the back end content provider. Although every phone I have tested uses "content://com.android.calendar/events" as the URI, that does not mean that it will always work as that can change (and has in the past) based on the version of Android running on the device.
Android 2.1 and before: content://calendar/calendars
Android 2.2 - 2.3: content://com.android.calendar/calendars
Related
I know this is way too general, but I have a reason. I am looking forward to make a simple app that can transfer strings from my mobile device to my TV. I wish to transfer this data over Wi-Fi, provided that the TV and my phone are on the same network. Now, the Android Documentation for the P2P Wireless APIs is DEAD. It even uses some deprecated implementations, and to worsen that up, nobody cared to provide an up to date documentation for carrying it out in modern day programming.
All I want, is a reference to a reliable source that might be helpful in understanding this. I added the compose tag, again, so that the info is conveyed that the app is built using a declarative paradigm, unlike the traditional android system. The sources may still be using the old android system (I, however, would prefer a Compose app). If nothing, at least point me to the correct (and updated) documentation, if it at all exists.
My app has a built in feature for creating in-app reminders, and it needs to support at least API 8 (Android 2.2). There is no problem adding a calendar event, but the problem begins when the user edits the reminder date in-app and expects that the calendar event related to the app data will change too.
Also, the app data is synchronised with a server, so I maybe should delete all old events from my app when syncing and re-create the new ones. But to do that I'll need to find the events that have been created by my app and I'm not entirely sure how I can find them (maybe by time and event title?)
From what I understand, editing or deleting calendar events is not officially supported in Android versions prior to 4.0, so it might not work on all devices, etc. Should I just tell my client that we should just support events in Android 4.0+?
Should I just tell my client that we should just support events in Android 4.0+?
IMHO, yes.
Note Questoins like should I ... yes/no are likely opinion based question that belongs to https://softwareengineering.stackexchange.com/ and are likely to be closed on http://stackoverflow.com.
If your question is how to use calender in android versions below 4.0 you can look at
Jim Blackler's Accessing the internal calendar database inside Google Android applications
where you basically query contentproviders where url and fields may differ depinding on manufacturer and android version (ie content://calendarEx or content://calendar or content://com.android.calendar). This is slightly different from the official android 4 api.
So you have to encapsulate this logic yourself and be prepared that it will not work on every prior andriod 4.0.
Microsoft Office Project 2007 introduces effective work weeks and
calendar exceptions, where all calendar data is associated with a set
of "valid from/to" dates.
--Microsoft Office Dev Center
Google also uses this feature.
Does Android Calendar (pre-ICS) support these features too? I tried Googling, but only found incomplete posts, such as https://stackoverflow.com/questions/13633577/android-8-sdk-14-recurring-event-exception.
I learned on a separate post that the way to access the calendar was through a content provider, however I have found no working solution
(for example, I tried using "content://com.android.calendar/exception", but it results in an exception saying that it is an unknown url).
Any help to steer me in the right direction would be extremely helpful, as I have been Googling to no avail, and this try and try again stuff is not working well.
No. Android Calendar exceptions are officially supported starting with ICS (API level 14):
-- Android Developer Guide
Some versions may allow you to use the Uri you discuss, since it is derived from the source code:
public static final String AUTHORITY = "com.android.calendar";
public static final Uri CONTENT_EXCEPTION_URI = Uri.parse("content://" + AUTHORITY + "/exception");
//hence, CONTENT_EXCEPTION_URI = Uri.parse("content://com.android.calendar/exception");
however since it is not officially supported, it should not be considered reliable.
To answer your first question, yes, older Android has ability to have exceptions to a repeating event.
Since that API was introduced in API 14, It's probably a lot different than the previous versions' code. This link has some hints on getting events from calendars on older versions.
I'm trying to develop an Android App which shows the signal strength of various network operators on a map. The problem is that the only way to change the network operator is by doing it by hand.
Any ideas on how I can get this information without changing it manually? I think that there are internal/private Android classes to do this.
You will need to use one or more of Google's internal APIs to do this. They are not, by default, available to Android applications for various (usually good) reasons. The API for turning tethering on and off and configuring it, for example, is not a public API and cannot be invoked directly by third party applications.
You will need to do two things. First, download the Android source code and find the API(s) you need to list and switch carrier. You can find the Android source code, and download instructions, here.
Second, you will need to use reflection to invoke the methods on those APIs. The best approach to this, and one I used myself to play with the tethering API, is to write a proxy class. Give it all the same methods as the API you want to use, and inside each method use reflection to invoke the API method. Any other technique will either (a) not compile without adding portions of the Android source code to your classpath and then (b) will compile but blow up when you deploy.
Be aware that you're best doing this on a Nexus branded device as this has the vanilla Android code on it. My (successful) attempt to write a home screen widget to turn tethering on and off worked on a Nexus One but did not work on a Samsung Galaxy Tab P1000. The device supported tethering, but Samsung had modified that part of the OS as part of their porting effort.
I would like to be able to detect all forms of data usage using the Android environment. Is it possible to keep tabs on which applications call on say RTP vs WAP, etc. such that I can know at all times when data is being used by a native program or third-party app?
If you are talking about an Android API to monitor network statistics by application then such an API seems to have been added in Android 2.2 (Froyo).
The main class you'll need is TrafficStats.
You can use getUid{Rx|Tx}Bytes(int uid) for the given process user ID (which you can get from ActivityManager.getRunningAppProcesses()).
The API is very simple and simply gives you the total bytes received/sent, so you'll have to do some more work to keep track of hourly, daily, and monthly stats. Well, that all depends on your needs.
I haven't tried using it myself, so I cannot give you any more detail, nor do I know the supported devices (not all devices will support this as the API points out).