I must've gone through ever Stack Overflow question based on the Google Calendar so far with no luck what so ever. I've been trying this for hours now and got little to no results at all.
I'm a pretty new programmer with Java and Android, with quite little experience out of the field as it is. Basically the main problem I am having is with viewing another user's Google Calendar which is set to public.
At the moment, from the Google tutorials and other sites I've managed to get the calendar showing, which is pretty simple enough. It'll just load up and show the current user's calendar. Which can literally be done with (with a simple button in the layout).
public void onClick(View view) {
// A date-time specified in milliseconds since the epoch.
long startMillis = System.currentTimeMillis();
Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon();
builder.appendPath("time");
ContentUris.appendId(builder, startMillis);
Intent intent = new Intent(Intent.ACTION_VIEW).setData(builder.build());
startActivity(intent);
}
Obviously this doesn't pass in any user data for the public account or anything, I've been reading through the Calendar Provider Developer guides within the Google tutorials. I've tried to set up the account details thing, but it just never works. I've tried to do it as a Sync Adapter, but honestly I just know I'm not doing it right. I don't know if I really even need to use a Sync Adapter as all I want to do is literally see the events, not modify anything or update anything.
I am using API 14+ and want to user the Calendar Provider etc. It looks simple enough but I've been bashing my head against this for a few days and put a lot of hours into it and seemingly nothing I do works. At least I've got some sort of calendar opening but it's not what I want.
Is it all just down to the sync adapter? If so how will I be able to call a calendar? Another question similar had
private static Uri buildCalUri() {
return CalendarContract.Calendars.CONTENT_URI
.buildUpon()
.appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
.appendQueryParameter(Calendars.ACCOUNT_NAME, ACCOUNT_NAME)
.appendQueryParameter(Calendars.ACCOUNT_TYPE, CalendarContract.ACCOUNT_TYPE_LOCAL)
.build();
}
I'm hoping this is something similar to what I need but I'm very unsure. In the developer tutorial ACCOUNT_TYPE_LOCAL was important if the account wasn't on the device
Any help will be greatly appreciated!
If you are looking to integrate the public Google Calendar (www.google.com/calendar) with your Android Application, you have to use the Google Calendar API.
The easiest method would be download the Google Calendar Client Library from here and then use the API Reference here. In the Client Library Page, you want to download "Google APIs Client Library for Java (rc)" package to integrate into your Android App.
You will first need to go to API Console to create an App with Calendar API Access .
If you do not want to use the native library, you can even do it using REST API (use HTTP GET & POST Commands), example App here
Hope this helps.
For anybody that has followed the Android Developer API example, but still can't find how to add a public calendar. Try out
CalendarListEntry gracieCal = new CalendarListEntry();
gracieCal.setId("your-public-calendar-id");
mService.calendarList().insert(gracieCal);
Events events = mService.events().list(gracieCal.getId())
.setMaxResults(10)
.setTimeMin(new DateTime(System.currentTimeMillis()))
.setOrderBy("startTime")
.setSingleEvents(true)
.execute();
List<Event> items = events.getItems();
'mService' is the com.google.api.services.calendar.Calendar instance that you should have already created. (see the api tutorials mentioned by the other answer)
'your-public-calendar-id' can be found in the settings for your public google calendar.
Related
On microsoft graph explorer i am able to retrieve the excel file easily but when trying on the "active-directory-android-native-v2-master" sample code, it returns 404.
On the the other hand, next line works and retrieves my information correctly
final static String MSGRAPH_URL = "https://graph.microsoft.com/v1.0/me";
I added all required permissions, got the client ID, run all the sample instructions, read the documentation + stack over flow.
I thought it might be because the link was not coded correctly so i modified the callGraphAPI() method to include:
Uri.Builder builder = new Uri.Builder();
builder.
scheme("https").
authority("graph.microsoft.com").
appendPath("v1.0").
appendPath("drives").
appendPath(MY_DRIVE).
appendPath("items").
appendPath(FILE_ID).
appendPath("workbook");
String url = builder.build().toString();
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET,url/*MSGRAPH_URL*/,
parameters,new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
but still the same response.
I came across the next stack overflow answer
404 file not found error when using microsoft graph api
And thought it might be the answer but then seen the question was old and another answer mentioned it is not longer correct.
appreciate any help.
It seems i was not aware using sample code for the V2 (active-directory-android-native-v2-master) while the graph explorer (which was working) used V1.
There is a great "getting started" tutorial for the V1 sample code (active-directory-android-master) here:
https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-v1-android
Sample code seems quite the same only for V1.
When using the tutorial, i needed to find the required permissions for the command i was trying to use, in addition to the one mentioned at the tutorial.
I used the next link to get the permissions for the items:
https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/shares_get
I also added the permissions mentioned at the Graph Exlorer since as noted, the command i was trying to use worked there.
Since the permissions at the Azure site was not written the same (e.g. Files.Read is written as "Read user files") i used the next link to translate:
https://developer.microsoft.com/en-us/graph/docs/concepts/permissions_reference
Luckily i did not need to use any admin permissions, which would have complicated the registration to the app
Hopes this helps any struggled newbie like me :)
If anything from what i wrote not correct or you think i should add something, please let me know at the comments below and i will try to update
BTW - i used the Graph Exlorer to detect the files & Drive ID items i needed
Here's some code that successfully shares a link to Facebook after a button click:
public void onClick(View view) {
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("A title")
.setContentDescription("Some description.")
.setContentUrl(Uri.parse("www.website.com"))
.build();
shareDialog.show(linkContent);
}
}
Using Android Studio, the ".setContentTitle" and ".setContentDescription" are deprecated, with a line through them. When I post the link, it is shared without the title and description. I assume this is because they are deprecated.
How could I add a title and description in? What were the deprecated terms replaced with? This isn't pre-filling a a post, and it wouldn't make sense for Facebook to get rid of these features completely. I have tried a few different links as the URL, none made a difference to this issue.
Many thanks in advance.
Edit: Please note that meta tags aren't an option, because if I were to link to an app in the Google Play Store, I can't control what tags the page has. I am looking to provide a title/description from the app, as was previously possible using the deprecated features mentioned.
I have found a suitable way around this, though not one that specifically replaces title and description. Another way to automatically add text to a post without pre-filling the user's text box is to use .setQuote().
For example with the code I provided above:
public void onClick(View view) {
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setQuote("This may be used to replace setTitle and setDescription.")
.setContentUrl(Uri.parse("www.website.com"))
.build();
shareDialog.show(linkContent);
}
}
If anyone knows a way to replace the deprecated functions properly, without such a different alternative like the one I just provided, please post it and I'll mark it as solved.
Many thanks.
You can use ShareOpenGraphContent that uses ShareOpenGraphAction and ShareOpenGraphObject.
Look at the code I answered in this question.
https://stackoverflow.com/a/46459350/4107421
That way you can add a title, description and even an image to your post.
It works for ShareDialog.show() but unfortunately on my experience it doesn't on MessageDialog.show()
I am able to create events programmatically which are added to my Google Calendar (API v3) fine, but none of these events have reminders on them. I have followed the answers on other SO questions and my reminder code looks like the following:
Event.Reminders reminders = new Event.Reminders()
.setUseDefault(false)
.setOverrides(Arrays.asList(
new EventReminder().setMethod("email").setMinutes(60),
new EventReminder().setMethod("popup").setMinutes(10)));
I have tried with setUseDefault(true) in place of the overrides and I still see nothing in the notifications section.
I tried adding setSendNotifications(true) but that hasn't been of any help adding the reminders themselves.
It might be worth noting that the account associated with this calendar uses an email that is not hosted through Google.
I have some new questions in today's citymaps development.
In the Android studio,if I develop the code for citymap, there are always no logs showing but for others that does not happen. Why?
According to the citymaps official website, to create a map instance with CitymapsMapFragment, but in the sample project which citymaps provides, it uses SupportCitymapsMpaFragment ,What is the difference between them?
When the map is loading complete, is it automatically positioning to the current position or some other default position? Where is it?
If I open the GPS location,I can locate to the current position and show a blue arrow quickly, but too much power consumption,are there any other location way like network or base station location?
Code follows:
CitymapsMapFragment fragment = (CitymapsMapFragment)fragmentManager.findFragmentById(R.id.map);
if (fragment != null) {
fragment.setMapViewListener(this);
}
I did not find the fragment have the method setMapViewListener but setMapViewReadyListener,does it right?
Other code:
CitymapsMapView mapView = new CitymapsMapView(this, options, this);
When I add animate in additional methods like this:
mapView.setMapPosition(position, 300, new MapViewAnimationListener() {
#Override
public void onAnimationEnd(boolean completed) {
Log.d("SomeApp", "Move Complete!");
}
});
the project fails and exits,I tried to surround the code with try-catch block to catch exception for purpose, but nothing shows in logcat view. Why?
I am developer on the Citymaps project. I will do my best to answer all your questions
1) If you are not receiving log statements, this is likely an issue with your own application, IDE, or device configuration. In our own application, which uses the Citymaps SDK, we have no issues with logging.
2) Prior to using the Citymaps SDK, it is highly advisable that you familiarize yourself with fragments, but the short version is that SupportCitymapsMapFragment extends from the Fragment class in the v4 support library.
3) It is up to you to set the default position the map.
4) If you create a class which implements from the LocationSource interface, and then call mapView.setLocationSource, you can modify the behaviors of the map's location services. For an example, have a look at CitymapsLocationSource.java, which is the default implementation for this interface used by the SDK.
As for the exception you are having, you have not provided nearly enough information. Please show a stack trace, and I may be able to help.
Thank you for using our SDK, feel free to post again with any more questions.
I'm developing one web application project using java for education industry.In this Admin have all rights to access the google services of other users like A,B,C..... for this is use OAuth.Then i tried Admin want to share user A's calendar to user B using OAuth.But i got stuck in this step. Is it possible Plz Help me
Thanks
Regards
Sharun
I believe you want to use Access Control Lists (ACLs), see the docs. The Java example code at this URL for the task you mention is pretty simple:
AclEntry entry = new AclEntry();
entry.setScope(new AclScope(AclScope.Type.USER, "jdoe#gmail.com"));
entry.setRole(CalendarAclRole.READ);
URL aclUrl =
new URL("http://www.google.com/calendar/feeds/jo#gmail.com/acl/full");
AclEntry insertedEntry = service.insert(aclUrl, entry);
and what it does is, and I quote:
This code allows jdoe#gmail.com to
have read-only access to
jo#gmail.com's calendar.
There's more where this came from (e.g., upgrading a user's role in an ACL above the read-only access granted in this example), and I think it's a good idea to read the whole page.