好吧,我的Android应用程序无法从我的移动服务中的表中获取数据 .
它使用MobileserviceClient连接到azure移动服务服务器,没有任何错误 . 但是,当我尝试获取一个表并从该表中取出数据时,该应用程序冻结在该1行并给我一个白色屏幕 .
所以一些帮助会很好,因为我不知道我做错了什么 . 此外,restaurantdata表中已有50行数据 .
private MobileServiceClient mClient;
private MobileServiceTable<RestaurantData> table;
private MobileServiceList<RestaurantData> list;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.activityMainToolbar);
setSupportActionBar(toolbar);
coordinatorLayout = (CoordinatorLayout) findViewById(R.id.activityMainCoordinatorLayout);
viewGroup = (ViewGroup) ((ViewGroup) this.findViewById(android.R.id.content)).getChildAt(0);
layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = layoutInflater.inflate(R.layout.activity_new_restaurants, viewGroup, false);
coordinatorLayout.addView(view);
try {
Log.e("Log", "Log1");
mClient = new MobileServiceClient("Service doamin", "application key here", getApplicationContext());
Log.e("Log", "Log2");
table = mClient.getTable(RestaurantData.class);
Log.e("Log", "Log3");
list = table.execute().get();//App freezes here with white screen
Log.e("Log", "Log4");
} catch (Exception e) {
e.printStackTrace();
Log.e("ERROR2", " " + e);
}
Log.e("Log", "Log6");
}
1 回答
根据您提供的代码段,您似乎只是通过
list = table.execute().get()
获取数据,但不会将您的数据呈现给视图 .通常,我们可以利用list view和adapter在列表中显示我们的数据 .
以下是Azure移动服务Android客户端示例的代码段:
}
define variables :
add list item in listview: