0
我是新來整合cumulocity SDK與android程序。 我想嘗試像下面的代碼一樣的cumulocity例子。用cumulocity SDK測試android程序
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();
}
}
當我運行 「inventory.create(MO);」 服務器總是返回。 //日誌
"Caused by: com.cumulocity.android.sdk.SDKException: The server returned 401: Unauthorized! "
我覺得這個問題可能在這個函數中。
platform = new PlatformImpl(host, port, tenantId, user, password, applicationKey);
我不知道這個函數中的「applicationKey」是什麼。 所以我在參數中使用「」。
是否有任何一個熟悉的cumulocity android sdk? 或任何其他方式來開發與cumulocity服務器的android程序?
應用程序密鑰用於標識正在進行呼叫的應用程序。您可以使用管理應用程序中的「自己的應用程序」創建應用程序,並在此設置應用程序密鑰你可以爲了測試目的而簡單地嘗試將參數設置爲「devicemanagement-application-key」(在這種情況下,它看起來像設備管理將進行呼叫)。 –