尝试从Azure表获取信息时为空消息

时间:2018-12-26 21:20:01

标签: android mysql azure android-studio

我正在尝试从Azure表中获取用户信息,并且收到此错误消息:

  

尝试在空对象引用上调用虚拟方法'com.microsoft.windowsazure.mobileservice.table.query.ExecutableQuery com.microsoft.mobileservice.table.MobileServiceTable.where()'。

我不明白的是,为什么有时它起作用,有时却不起作用。

private MobileServiceTable<trainer> TrainerTable = null;
private MobileServiceClient mService = null;
private users cl = null;
private ProgressDialog prg;

private void Trainer_Club_String(final String username)
{
    AsyncTask<Void,Void,Void> task = new AsyncTask<Void, Void, Void>()
    {
        @Override
        protected Void doInBackground(Void... voids)
        {
            try
            {
                List<trainer> chosen_manager= TrainerTable.where().field("username").eq(username).execute().get(); \\the problem is in this line Im pretty sure. Sometimes it tells me that the user is null and sometimes its working well.

                if(chosen_manager.size()>0)
                {
                    trainer_club=chosen_manager.get(0).getClub().toString();
                }

            }

            catch (Exception e)
            {
                final String message=e.getMessage().toString();

                runOnUiThread(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        Toast.makeText(trainer_home_page.this, message, Toast.LENGTH_LONG).show();
                    }
                });
            }
            return null;
        }
    }.execute();
} 

ONCREATE:


cl=StaticObjects.GetClient();

trainer_username=cl.getUsername().toString();

Trainer_Club_String(trainer_username);

0 个答案:

没有答案