显然这是一个安全问题,但是从网站下载的示例工作正常(ToDo),我的应用程序更简单,不起作用,因为我真的不明白,我检查了库,宣言,代码,一切似乎都是正确的. 我究竟做错了什么?我之前对这个问题有一个悬而未决的问题,但现在我想我可以最好地描述这个问题
错误:未经授权
完全错误:活动 com.microsoft.windowsazure.mobileservices.MobileServiceException 中的错误:处理请求时出错。在 com.microsoft.windowsazure.mobileservices.MobileServiceConnection$1.onNext 在 com.microsoft.windowsazure.mobileservices.MobileServiceClient$4.handleRequest 在 com.microsoft.windowsazure.mobileservices.MobileServiceConnection.start 在 com.microsoft.windowsazure.mobileservices.RequestAsyncTask.doInBackground at com.microsoft.windowsazure.mobileservices.RequestAsyncTask.doInBackground at android.os.AsyncTask$2.call at java.util.concurrent.FutureTask$Sync.innerRun at java.util.concurrent.FutureTask.run at android.os.AsyncTask$ SerialExecutor$1.run at java.util.concurrent.ThreadPoolExecutor.runWorker at java.util.concurrent.ThreadPoolExecutor$Worker.run at java.lang。
package com.bn7.rota;
import java.net.MalformedURLException;
import com.bn7.rota.Item;
import com.microsoft.windowsazure.mobileservices.*;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
public class MainActivity extends Activity {
private MobileServiceClient mClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
mClient = new MobileServiceClient(
"https://bn7.azure-mobile.net/",
"hCzcrsFYhkGmxPvQDNxyqBXjZwjXlK99",
this
);
Item item = new Item();
item.IdPhone = "Awesome item";
item.DateTimePhone = "2013/04/02 08:27:32";
item.LatitudePhone = -43;
item.LongetudePhone = -23;
item.Active = false;
mClient.getTable(Item.class).insert(item, new TableOperationCallback<Item>() {
public void onCompleted(Item entity, Exception exception, ServiceFilterResponse response) {
if (exception == null) {
// Insert succeeded
} else {
// Insert failed
Log.d("Insert failed", "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
Log.d("Insert failed", "Error in activity", exception);
Log.d("Insert failed", "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
}
}
});
} catch (MalformedURLException e) {
Log.d("MalformedURLException", e.toString());
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
package com.bn7.rota;
public class Item {
public int Id;
public String IdPhone;
public String DateTimePhone;
public double LatitudePhone;
public double LongetudePhone;
public boolean Active;
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bn7.rota"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.bn7.rota.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>