Is it possible to access and update Exchange accounts? - android

In my project I need to access the Exchange accounts on the device, to change them.
I need to do it programatically , inside my application.
I have searched around but it does not seem that there is a way of doing such a thing.
Please any help or suggestion?
EDIT EDIT
To be more specific i need to:
lists all email accounts on the device and allows the user to change settings for Exchange accounts:
*server address
*server port number
*SSL (on/off)
*accept all SSL certificates (on/off)
*account password

You can't modify the permissions/settings of an another exchange account (it gives you a security error). You only can create your own exchange account witch it will be included in your exchange accounts as yourAppName..

Take a look at AccountManager (http://developer.android.com/reference/android/accounts/AccountManager.html)
You should be able to do something like this:
AccountManager accountManager = AccountManager.get(context);
Account[] accountList = accountManager.getAccounts();
for(Account account : accountList){
accountManager.getUserData(account, AccountManager.KEY_USERDATA);
accountManager.setUserData(account, AccountManager.KEY_USERDATA, "data");
}

Powershell is probably the tool that I would want to use to do this, but from devices it is tricky. Tools like AccountManager should assit with this as under the hood they are probably using Remote Powershell scripting. Alternatives that I can think of are:
Create your own web service that you can execute powershell commands from, and have your app connect to that. This is a good primer that works for Exchange 2010 and 2013: http://forums.asp.net/t/1683553.aspx?Mailbox+creation+in+Exchange+Server+2010+using+ASP+Net+3+5+application
Find a tool to execute remote powershell requests from the device direct. I have not tried this but this looks like a good thread to follow: http://social.technet.microsoft.com/Forums/windowsserver/en-US/bc1b417d-0388-486b-8742-305a48224a92/android-client-for-powershell-remote-scripting?forum=winserverpowershell
I personally already had web services hosted inside the domain that my app was using anyway (data source was in the domain), so I put my mailbox and AD user management service along side those, then the mobile apps made simple calls like CreateUser, EnableMailbox, CreateMailEnabledUser...

Related

Registering a Google account to Android device programmatically

I've been looking for a solution to this problem for a while (days, not minutes), but it eludes me quite effectively.
Please note that this is NOT a question about starting up the registration procedure. This must happen automatically without any user interaction.
I would like to add a Google account to my custom device (1000's of them). The account will mostly be used to activate Google Play store on the device so that the app can update when newer versions are available.
My existing code (the shortest snippet of those I tried):
AccountManager mgr = AccountManager.get(this);
Account acc = new Account("email#gmail.com", "com.google");
mgr.addAccountExplicitly(acc, "password", new Bundle()));
naturally yields a
java.lang.SecurityException: caller uid 10047 is different than the authenticator's uid
So how would I go about actually achieving this? My device is rooted so that's not an obstacle if it's the only way.
It is not possible to add/create a Google account using addAccountExplicitly(). You can only add accounts for your own services. even your device is rooted because it will rejected by Google web server. For more detail check this link
Warning: this solution doesn't work well. See comments for explanation.
Well, as it turns out, this is not something easily solved. I ended up registering one device, then pulled the users file from it. Location of users file : /data/system/users/0/accounts.db (if there are multiple user profiles on the device, the last directory may differ according to profile in question).
I stored this file into my app's assets (gzipped, make sure the extension is not something.gz because that gets lost during packaging - didn't bother checking out why).
First I check if my user already exists:
AccountManager mgr = AccountManager.get(this);
for (Account acc: mgr.getAccountsByType("com.google")) {
if (acc.name.equalsIgnoreCase("email#gmail.com"))
return;
}
If it does, I just skip the step. Otherwise I unpack the users file and overwrite existing one (using su). I then also do a reboot to make sure changes are registered.

What is the APP­KEY in Truecaller API?

I need to verify the spam score of mobile numbers using Truecaller API .I found documentation here . In the API URL , I need to send a APPKEY , But how to get that ? there is no registration page for Truecaller API .
https://api.truecaller.com/v1.0/search.json?userKey=APP­KEY&phone=NUMBER
Any help will be appreciated...
You should Read this Document for Name Search API
it Says that....
The one thing to keep in mind is that all requests to our API require
authentication. For that, you will need to use a User Key (userKey)
along with your requests. These access details basically associate,
your server, script or program with a specific application. All
requests to the API must be made over SSL (https:// not http://).
It means you have registered Truecaller developer account then Do Login and get your Access Key(USER KEY) and pass it everytime you request to access API..
But I Think Truecaller API is not accessible for public users...
Read This Article for More Details : http://www.3scale.net/2013/05/truecaller-api-search-among-over-600-million-phone-numbers-worldwide/
Why don't you try this?
callerpy
Here is the explanation from the developer:
Truecaller Name Retriever.
Since my request for the API was rejected, I commenced using python parsing libraries.
Callerpy emulates the process one would encounter if using a web-browser.
I tried it, and it works like a charm from the command line.

Ijetty deployed war, need ijetty's context

I am using ijetty and I have a war deployed on it. One service it provides it to send emails out from the phone remotely. The recipients/subject/body are all POSTed to the server and I want to send them out of the phone.
I am using this method and it send the mail fine but I need the users credentials. Even if I could just get the email and then the user posted the password that would be fine but to do this I need to use
AccountManager accountManager = AccountManager.get(context);
The problem is that I do not know how to get ijetty's context so that I can get the accounts.
If anyone can help or provide some other direction I would greatly appreciate it.
Ok so I got an awnser from the ijetty mailing list and here it is,
android.content.ContentResolver resolver =
(android.content.ContentResolver)getServletContext().getAttribute("org.mortbay.ijetty.contentResolver");
android.content.Context androidContext =
(android.content.Context)getServletContext().getAttribute("org.mortbay.ijetty.context");
With these 2 objects you should be able to do what you want. Alternatively,
you could always subclass i-jetty to provide access to more android objects.

e-mail and Android mail account settings from code

Is there a way to create/change an email account from source at android an ios? We would like to provide our customer a way for adding their mail accounts to android and ios devices within in an app.
I've already taken a look at the Android Account Manager but I'm still not sure if I can add System-Mail Accounts with it(example..?) :(
API: Android Account Manager
For IOS up to now i haven't found anything :(
For iOs you will have to create a configuration profile using the iPhone Configuration Utility for Mac OS X or for Windows. Basically those are XML/Plist-Files - only some content is obfuscated (like passwords). But if you don't include passwords you can modify this xml content in your app then you should be able to create a local NSURL and call UIApplication's openURL. if that doesn't work you'll have to deploy your configurations from a webserver - there is a guide for that. In that case you have to create a http-NSURL and pass that to openURL.

Sync Adapter without Account

I need to fetch some data over the cloud from my app. I've watched the google IO video on RESTful android apps # http://www.youtube.com/watch?v=xHXn3Kg2IQE&t=43m58s It recommends in the final slides to use a SyncAdapter to integrate with the Android System.
Later I learned that one has to use an Account to implement SyncAdapter. My app does not use an account. Users can freely download data without registration. Can I still use SyncAdapter? Is there a stock dummy account that I could use?
Edit: I do have a content provider for my app so that's not a problem
Edit2: I've just looked at the Weather and Stock apps under Settings -> Accounts & Sync. You can see that they allow syncing, but don't have a remove account button. On the other hand, Google, Facebook and Skype apps allow syncing PLUS they have a remove account button. This means Weather and Stock don't use accounts, whereas Google, Facebook and Skype do.
The tutorials I found # http://ericmiles.wordpress.com/2010/09/22/connecting-the-dots-with-android-syncadapter/ and # http://www.c99.org/2010/01/23/writing-an-android-sync-provider-part-1/ say that one MUST have an account to use Sync Adapter. :S ???
As the Android Developer docs say
Even if your app doesn't use accounts, you still need to provide an authenticator component. If you don't use accounts or server login, the information handled by the authenticator is ignored, so you can provide an authenticator component that contains stub method implementations. You also need to provide a bound Service that allows the sync adapter framework to call the authenticator's methods.
There is an entire article on Creating a Stub Authenticator. I realise that this question is old and an answer was accepted long ago, but I felt that a recent addition to the official docs should be included here.
I have created a contact sync adapter where I don't have a account authorization and or configuration screens. It wasn't that hard. I don't think having to deal with the Android Account stuff was that much of a deal.
Quote from your tutorial link:
The bad news is that there is no
“stock” functionality to give you an
easy way to provide an Account to the
system. However, in the same Sync
Adapter Example that comes with the
SDK there is a lot of code you can
borrow to give you Account
functionality. Unless you desire a
custom credentials screen, you can
heist all the code in the
com.example.android.samplesync.authenticator
package with only a few minor changes.
So it's basically just a copy and paste from the example, that's pretty much what I did and it worked fine.
I don't know for sure but all the adapters that don't have "Remove Account" seems to be built-in ROM adapters on all the devices I've looked at. I'm not sure you have to worried about it.
I keep getting lots of notifications from this question, so I thought I'll share this info. This is how you add SyncAdapter without Account. You can put this in onCreate of MyApplication extends Application class. This assumes you already have a SyncAdapter and ContentProvider implemented. You can do that by following the tutorials listed in the question.
final String ACCOUNT_NAME = "MyApp";
final String ACCOUNT_TYPE = "com.myapp.account";
final String PROVIDER = "com.myapp.provider";
Account appAccount = new Account(ACCOUNT_NAME,ACCOUNT_TYPE);
AccountManager accountManager = AccountManager.get(getApplicationContext());
if (accountManager.addAccountExplicitly(appAccount, null, null)) {
ContentResolver.setIsSyncable(appAccount, PROVIDER, 1);
ContentResolver.setMasterSyncAutomatically(true);
ContentResolver.setSyncAutomatically(appAccount, PROVIDER, true);
}
res/xml/syncadapter.xml
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:contentAuthority="#string/provider"
android:accountType="#string/account_type"
android:userVisible="true"
android:supportsUploading="true"
/>
res/xml/authenticator.xml
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="#string/account_type"
android:icon="#drawable/app_icon"
android:smallIcon="#drawable/app_icon"
android:label="#string/app_label"
/>

Categories

Resources