how save value in android to acces other page - java

in android how we save one value to acces on each page,
for example I am making a login app
and I need user_id to each page for access data from db by this id
or
I am in home page and I want to store user_id ,and I need to access this on any page ,
for example home=>profile=> change password,
I want to access user_id here to change password
I am trying
Intent slideactivity = new Intent(login.this, LoginMenu.class);
slideactivity.putExtra("uName", n);
but When I access it it give empty value on create_password activity

You can use Shared Preferences. Please have a read.
http://developer.android.com/guide/topics/data/data-storage.html#pref
Hope this helps.

Also... a previous stackoverflow answer may help you out in this scenario. Have a look here...
How do I pass data between Activities in Android application?
Hope this also helps.

Related

Android Studio - URL string

So I'm pretty new to the whole Android Studio thing and I've been using the internet to help me with a lot of the things I am doing and needed help on something.
I'm not sure if it's possible to connect this to either a string or an SQL database but I have a Main Layouts with a bunch of buttons that allow me to click on them and choose what external player I would like to use to watch the video. In my MainActivity java class, this is how it finds the button.
case R.id.button3:
intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("http://videoname.mp4"), "video/*");
startActivity(Intent.createChooser(intent, "Choose an External Player"));
break;"
I wanted to know if "http://videoname.mp4" url can be connected to like a string where I can always update or change the URL instead of manually going to find the URL in the MainActivity java and changing it. As of now I have to manually do it but a different way to do it would be helpful.
I'm sorry if it's all confusing, but if you know, please let me know as soon as.
Thank you.
you just need write your string URL :
open your directory folder /res/values/strings.xml -> write your string : <string name="yourStringName>yourStringURL</string>. to use your string do this
getContext().getString(R.string.yourStringName) in fragment
getString(R.string.yourStringName) in Activity
or you can write directly on your code, put your cursor on your string, then press key alt + enter choose extract string resource fill the resource name with your string name
wherever you need to use it, just do point 1 or 2. also in your Intent
hope this help you, never stop learning!
Add it to strings.xml in your project. That is the recommended way of using strings anyway.

Using textfields and a grid in another page

I need to know how to take info from the user in one page using a label and textfield and displaying that in a grid in another page.
For example, Im getting the name of the user and displaying their name in following page in a grid. I'm using eclipse and working with vaadin, if that helps.
if what you need is an info from connected user, I suggest you to set the User object as Session Attribute.
IE:
User connectedUser = new User();
VaadinSession.getCurrent().setAttribute(User.class, connectedUser);
Then, if you need to pick this information, you just have to call
User currentUser = (User) VaadinSession.getCurrent().getAttribute(User.class);
Then, you can pick with all your getter all the required infos, like
String username = currentUser.getUsername();
In my opinion the best approach is to set the user attribute after his login, so you can have it everywhere you need to pick it from any class of your Vaadin application.
Hope this helps.
Bye

Mixare - How to display local data

After a make a call for a web service to get POIs from a database and show them in a list, I then click a button that opens up the camera displaying these POIs thanks to Mixare that I imported into my app. The problem is that Mixare only accepts URLs to be passed on to get data. Like so :
Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse("http://ws.geon ames.org/findNearbyWikipediaJSON"), "application/mixare-json");
startActivity(i);
Has anyone succeeded to use local data in Mixare ?
NB: I can't make another call to the web service, I want to be able to use the data I already have

Google+ API - issue getting posts on business page

So I am using java API to get public posts from a google+ business page.
` String businessPageId = "104451189002914239318"; `
`List<Activity> activities = plus.activities().list(businessPageId, "public").execute().getItems(); // no activities returned `
Even though there are public posts, the above call does not return any posts.
I did discover that , getting the Person for that page as
`String personId = plus.people().get(businessPageId).execute().getId();`
and using personId instead of businessPageId gets the posts.
What does the above call represent.? is it the page owner.?
Can anyone shed light what's going on here.?
It's two pages that have been merged together. If you visit https://plus.google.com/104451189002914239318 you will see it redirect to https://plus.google.com/108277438040092360159. Use the second ID and you should be all set.

Google Calendar

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.

Categories