I am new to integrate the cumulocity SDK with android program. I want to try cumulocity example like below code.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView mTextView = (TextView) findViewById(R.id.text1);
new AsyncTask<Object, Object, Object>() {
@Override
protected Object doInBackground(Object... arg0) {
Log.i("Richard debug","richard 1");
Platform platform = new PlatformImpl(
"https://developer.cumulocity.com", "<teanant id>", "<user>",
"<password>","<unknow>");
Log.i("Richard debug","richard 2");
InventoryApi inventory = platform.getInventoryApi();
Log.i("Richard debug","richard 3");
ManagedObjectRepresentation mo = new ManagedObjectRepresentation();
Log.i("Richard debug","richard 4");
mo.setName("Hello, Android!");
Log.i("Richard debug","richard 5");
mo = inventory.create(mo);
Log.i("Richard debug","URL: " + mo.getSelf());
return null;
}
}.execute();
}
}
When i run "inventory.create(mo);" The server always return. //Log
"Caused by: com.cumulocity.android.sdk.SDKException: The server returned 401: Unauthorized! "
I think the problem maybe in this function.
platform = new PlatformImpl(host, port, tenantId, user, password, applicationKey);
I don't know what's the "applicationKey" in this function. So i use the "" in the parameter.
Is there have any one familiar cumulocity android sdk? Or any other way to developing the android program with cumulocity server?