hello world(android volley)
来源:互联网 发布:杭州橙速网络怎么样 编辑:程序博客网 时间:2024/06/06 12:19
1、下载jar包
http://mvnrepository.com/artifact/com.mcxiaoke.volley/library
http://central.maven.org/maven2/com/mcxiaoke/volley/library/1.0.19/library-1.0.19.jar
2、file -> new ->new module 导入库
3、file -> project stucture -> app ->module dependency
4、添加MyApplication.java类
package com.nndou.yy.volleytest;import android.app.Application;import com.android.volley.RequestQueue;import com.android.volley.toolbox.Volley;/** * Created by yy on 16/6/23. */public class MyApplication extends Application { public static RequestQueue queue; @Override public void onCreate() { super.onCreate(); queue = Volley.newRequestQueue(getApplicationContext()); } public static RequestQueue getHttpQueue(){ return queue; }}
4、修改mainfest文件
<uses-permission android:name="android.permission.INTERNET" /><application android:name=".MyApplication"
5、测试代码
private void show(){ StringRequest stringRequest = new StringRequest("http://www.nndou.com", new Response.Listener<String>() { @Override public void onResponse(String response) { //Log.d("TAG", response); Toast.makeText(getApplicationContext(),response.toString(),Toast.LENGTH_LONG).show(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("TAG", error.getMessage(), error); } }); MyApplication.getHttpQueue().add(stringRequest);}
在合适的地方调用即可。
0 0
- hello world(android volley)
- 10.2 Hello World! Hello Android!
- Android的Hello World
- android入门--hello world
- android之Hello World!
- android--hello world
- Android Hello World
- Android之Hello World
- android--Hello,World教程
- Android Hello World
- Android入门-Hello World
- Hello Android World!
- Android hello world
- android ndk hello,world!
- phonegap android hello world
- android hello world
- android的Hello world
- Android Hello World
- Test
- winpcap环境搭建Visual Studio 2010
- 阿里面经之解答 by cmershen(4)——线程池
- android Handler 用法
- angularjs踩过的那些坑
- hello world(android volley)
- usage of map
- intentservice源码分析
- 判断元素入栈/出栈的合法性
- Android Studio 串口jni开发
- %20与空格
- Servlet中路径详解
- 欢迎使用CSDN-markdown编辑器
- php在范围中取值并使和为100