非常感谢任何帮助。我使用适用于Android Studio的Microsoft Azure Mobile SDK为我的Android应用程序创建了一个后端。但是当我尝试使用查询从服务器获取数据时,应用程序会挂起并崩溃。我的代码如下:
//The variables
private MobileServiceClient mClient;
private MobileServiceTable<Item> table;
//In onCreate method
try {
mClient = new MobileServiceClient("https://myapp.azurewebsites.net", this);
} catch (MalformedURLException e) {
e.printStackTrace();
}
table = mClient.getTable("MyTable",Item.class);
try {
final List<Item> result = table.execute().get();//----App crashes here
} catch (MobileServiceException e) {
e.printStackTrace();
}
答案 0 :(得分:1)
@AnshaySaboo有两个名为Azure Mobile Services
的服务(Azure经典门户网站上的旧服务)&amp; Azure上的Azure Mobile Apps
(Azure新门户上的新服务)。根据您的描述,我无法识别您使用的是哪种服务。但是,根据构造函数MobileServiceClient(String appUrl, Context context)
,我认为您使用的是Azure Mobile Apps SDK for Android,而不是Azure Mobile Services SDK for Android。
我认为当您在Azure新门户上创建移动应用服务时,可能会因使用适用于Android的移动服务SDK而导致此问题。因此,请检查您用作后端的服务以及您用于Android客户端的sdk,并确保后端和客户端的服务一致性。
作为参考,有一些资源可用于不同的服务。