parent
b8ebc218ec
commit
d30395d631
|
@ -46,6 +46,10 @@
|
|||
android:name=".FindActivity"
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.example.bmob_test_pull.QueryActivity"
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
|
|
|
@ -46,6 +46,10 @@
|
|||
android:name=".FindActivity"
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.example.bmob_test_pull.QueryActivity"
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,7 @@
|
|||
package com.example.bmob_test_pull;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
|
@ -16,7 +17,7 @@ public class CreateActivity extends Activity{
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
final Person p2 = new Person();
|
||||
p2.setName("lucky");
|
||||
p2.setName("verylucky");
|
||||
p2.setAddress("北京东城");
|
||||
|
||||
// //final String temid = p2.getObjectId();
|
||||
|
@ -42,10 +43,12 @@ public class CreateActivity extends Activity{
|
|||
String idget = p2.getObjectId();
|
||||
toast("what" + idget);
|
||||
|
||||
Intent intent =new Intent(CreateActivity.this,FindActivity.class);
|
||||
startActivity(intent);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void toast(String toast) {
|
||||
|
|
|
@ -12,8 +12,10 @@ import cn.bmob.v3.Bmob;
|
|||
import cn.bmob.v3.BmobQuery;
|
||||
import cn.bmob.v3.BmobQuery.CachePolicy;
|
||||
import cn.bmob.v3.listener.FindListener;
|
||||
import cn.bmob.v3.listener.GetListener;
|
||||
import cn.bmob.v3.listener.SaveListener;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.example.bmob_test_pull.model.Person;
|
||||
|
@ -22,37 +24,31 @@ public class FindActivity extends Activity{
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// BmobQuery<Person> query = new BmobQuery<Person>();
|
||||
// query.addWhereEqualTo("objectID", shopID);
|
||||
// query.setCachePolicy(CachePolicy.CACHE_ELSE_NETWORK); //
|
||||
// // 先从缓存取数据,如果没有,再从网络取。
|
||||
// query.setLimit(15); // 限制最多15个结果
|
||||
// query.findObjects(this, new FindListener<Good>() {
|
||||
//
|
||||
// @Override
|
||||
// public void onSuccess(List<Good> goods) {
|
||||
// // toast("查询商品成功, 共" + goods.size());
|
||||
// if (goods.size() == 0) {
|
||||
// toast("该店还没有添加商品");
|
||||
// }
|
||||
// goodsList = goods;
|
||||
// goodsListAdapter.refresh(goodsList);
|
||||
// goodsListAdapter.notifyDataSetChanged();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(int arg0, String arg1) {
|
||||
// toast("查询失败");
|
||||
// }
|
||||
// });
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BmobQuery<Person> query = new BmobQuery<Person>();
|
||||
query.getObject(this, "2b86628bc3", new GetListener<Person>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(int code, String arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
toast("查询失败:" + arg0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Person arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
toast("查询成功:" + arg0.getName() + arg0.getAddress());
|
||||
Log.i("查询成功:" , arg0.getObjectId() + arg0.getAddress());
|
||||
//获得数据的信息
|
||||
|
||||
Intent intent =new Intent(FindActivity.this,QueryActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void toast(String toast) {
|
||||
Toast.makeText(this, toast, Toast.LENGTH_SHORT).show();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package com.example.bmob_test_pull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
import cn.bmob.v3.Bmob;
|
||||
import cn.bmob.v3.BmobQuery;
|
||||
import cn.bmob.v3.BmobQuery.CachePolicy;
|
||||
import cn.bmob.v3.listener.FindListener;
|
||||
import cn.bmob.v3.listener.GetListener;
|
||||
import cn.bmob.v3.listener.SaveListener;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.example.bmob_test_pull.model.Person;
|
||||
|
||||
public class QueryActivity extends Activity{
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
BmobQuery<Person> query = new BmobQuery<Person>();
|
||||
query.addWhereEqualTo("address", "北京海淀");
|
||||
query.setLimit(50);
|
||||
//执行查询方法
|
||||
query.findObjects(this, new FindListener<Person>() {
|
||||
|
||||
@Override
|
||||
public void onError(int arg0, String arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
Log.i("bmob","失败:" + "Code:" + arg0 + "Info:" + arg1);
|
||||
toast("bmobfailure:" + "Code:" + arg0 + "Info:" + arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<Person> arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
Log.i("bmob", "成功:" + "共计: " + arg0.size());
|
||||
toast("bmobsuccess: " + "共计: " + arg0.size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void toast(String toast) {
|
||||
Toast.makeText(this, toast, Toast.LENGTH_SHORT).show();
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue