- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发我的第一个 Android 应用程序,并且主要基于研究内置。当我尝试登录我的用户时,我得到了 android.os.NetworkOnMainThreadException
错误。我在网上读到应该使用 Async 来确保不会发生此错误,但我不知道该怎么做。
下面是我所有的代码。
我的用户登录表单事件:
import java.util.HashMap;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.finecalc.library.DatabaseHandler;
import com.finecalc.library.UserFunctions;
public class UserLogin extends Activity {
Button userlogin;
Button back;
Button login;
EditText inputEmail;
EditText inputPassword;
TextView loginErrorMsg;
// JSON Response node names
private static String KEY_SUCCESS = "success";
private static String KEY_ERROR = "error";
private static String KEY_ERROR_MSG = "error_msg";
private static String KEY_UID = "uid";
private static String KEY_NAME = "name";
private static String KEY_EMAIL = "email";
private static String KEY_CREATED_AT = "created_at";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_login);
// Importing all assets like buttons, text fields
inputEmail = (EditText) findViewById(R.id.inputemail);
inputPassword = (EditText) findViewById(R.id.inputpassword);
login = (Button) findViewById(R.id.login);
//Button register = (Button) findViewById(R.id.register);
back =(Button)findViewById(R.id.back);
loginErrorMsg = (TextView) findViewById(R.id.login_error);
// Login button Click Event
login.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
String email = inputEmail.getText().toString();
String password = inputPassword.getText().toString();
UserFunctions userFunction = new UserFunctions();
JSONObject json = userFunction.loginUser(email, password);
// check for login response
try {
//if (json.getString(KEY_SUCCESS) != null) {
if(json != null && !(json).isNull(KEY_SUCCESS)){
loginErrorMsg.setText("");
String res = json.getString(KEY_SUCCESS);
if(Integer.parseInt(res) == 1){
// user successfully logged in
// Store user details in SQLite Database
DatabaseHandler db = new DatabaseHandler(getApplicationContext());
JSONObject json_user = json.getJSONObject("user");
// Clear all previous data in database
userFunction.logoutUser(getApplicationContext());
db.addUser(json_user.getString(KEY_NAME), json_user.getString(KEY_EMAIL), json.getString(KEY_UID), json_user.getString(KEY_CREATED_AT));
// Launch Dashboard Screen
Intent dashboard = new Intent(getApplicationContext(), DashboardActivity.class);
// Close all views before launching Dashboard
dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(dashboard);
// Close Login Screen
finish();
}else{
// Error in login
loginErrorMsg.setText("Incorrect username/password");
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}
}
import java.util.HashMap;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DatabaseHandler extends SQLiteOpenHelper {
// All Static variables
// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "androidlta_api";
// Login table name
private static final String TABLE_LOGIN = "login";
// Login Table Columns names
private static final String KEY_ID = "id";
private static final String KEY_NAME = "name";
private static final String KEY_EMAIL = "email";
private static final String KEY_UID = "uid";
private static final String KEY_CREATED_AT = "created_at";
public DatabaseHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
// Creating Tables
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_LOGIN_TABLE = "CREATE TABLE " + TABLE_LOGIN + "("
+ KEY_ID + " INTEGER PRIMARY KEY,"
+ KEY_NAME + " TEXT,"
+ KEY_EMAIL + " TEXT UNIQUE,"
+ KEY_UID + " TEXT,"
+ KEY_CREATED_AT + " TEXT" + ")";
db.execSQL(CREATE_LOGIN_TABLE);
}
// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + TABLE_LOGIN);
// Create tables again
onCreate(db);
}
/**
* Storing user details in database
* */
public void addUser(String name, String email, String uid, String created_at) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_NAME, name); // Name
values.put(KEY_EMAIL, email); // Email
values.put(KEY_UID, uid); // Email
values.put(KEY_CREATED_AT, created_at); // Created At
// Inserting Row
db.insert(TABLE_LOGIN, null, values);
db.close(); // Closing database connection
}
/**
* Getting user data from database
* */
public HashMap<String, String> getUserDetails(){
HashMap<String,String> user = new HashMap<String,String>();
String selectQuery = "SELECT * FROM " + TABLE_LOGIN;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// Move to first row
cursor.moveToFirst();
if(cursor.getCount() > 0){
user.put("name", cursor.getString(1));
user.put("email", cursor.getString(2));
user.put("uid", cursor.getString(3));
user.put("created_at", cursor.getString(4));
}
cursor.close();
db.close();
// return user
return user;
}
/**
* Getting user login status
* return true if rows are there in table
* */
public int getRowCount() {
String countQuery = "SELECT * FROM " + TABLE_LOGIN;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(countQuery, null);
int rowCount = cursor.getCount();
db.close();
cursor.close();
// return row count
return rowCount;
}
/**
* Re crate database
* Delete all tables and create them again
* */
public void resetTables(){
SQLiteDatabase db = this.getWritableDatabase();
// Delete All Rows
db.delete(TABLE_LOGIN, null, null);
db.close();
}
}
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import android.content.Context;
import android.util.Log;
public class UserFunctions {
private JSONParser jsonParser;
// Testing in localhost using LAMP
private static String loginURL = "http://127.0.0.1/android_api/index.php";
private static String registerURL = "http://127.0.0.1/android_api/index.php";
private static String login_tag = "login";
private static String register_tag = "register";
// constructor
public UserFunctions(){
jsonParser = new JSONParser();
}
/**
* function make Login Request
* @param email
* @param password
* */
public JSONObject loginUser(String email, String password){
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("tag", login_tag));
params.add(new BasicNameValuePair("email", email));
params.add(new BasicNameValuePair("password", password));
JSONObject json = jsonParser.getJSONFromUrl(loginURL, params);
// return json
// Log.e("JSON", json.toString());
return json;
}
/**
* function make Login Request
* @param name
* @param email
* @param password
* */
public JSONObject registerUser(String name, String licencenumber, String email, String password){
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("tag", register_tag));
params.add(new BasicNameValuePair("name", name));
params.add(new BasicNameValuePair("licencenumber",licencenumber));
params.add(new BasicNameValuePair("email", email));
params.add(new BasicNameValuePair("password", password));
// getting JSON Object
JSONObject json = jsonParser.getJSONFromUrl(registerURL, params);
// return json
return json;
}
/**
* Function get Login status
* */
public boolean isUserLoggedIn(Context context){
DatabaseHandler db = new DatabaseHandler(context);
int count = db.getRowCount();
if(count > 0){
// user logged in
return true;
}
return false;
}
/**
* Function to logout user
* Reset Database
* */
public boolean logoutUser(Context context){
DatabaseHandler db = new DatabaseHandler(context);
db.resetTables();
return true;
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;
import android.util.Log;
public class JSONParser {
static InputStream is = null;
static JSONObject jObj = null;
static String json = "";
// constructor
public JSONParser() {
}
public JSONObject getJSONFromUrl(String url, List<NameValuePair> params) {
// Making HTTP request
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "n");
}
is.close();
json = sb.toString();
// Log.e("JSON", json);
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
// try parse the string to a JSON object
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
// return JSON String
return jObj;
}
<uses-permission android:name="android.permission.INTERNET" />
.
08-02 04:39:23.410: D/(2642): HostConnection::get() New Host Connection established 0xb97a3b90, tid 2642
08-02 04:39:23.480: W/EGL_emulation(2642): eglSurfaceAttrib not implemented
08-02 04:39:23.480: D/OpenGLRenderer(2642): Enabling debug mode 0
08-02 04:39:29.150: W/EGL_emulation(2642): eglSurfaceAttrib not implemented
08-02 04:39:33.650: D/InputEventConsistencyVerifier(2642): KeyEvent: ACTION_UP but key was not down.
08-02 04:39:33.650: D/InputEventConsistencyVerifier(2642): in android.widget.EditText{b1fa92d8 VFED..CL .F...... 0,82-240,118 #7f07001c app:id/inputpassword}
08-02 04:39:33.650: D/InputEventConsistencyVerifier(2642): 0: sent at 7133734000000, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_TAB, scanCode=15, metaState=0, flags=0x8, repeatCount=0, eventTime=7133734, downTime=7133655, deviceId=0, source=0x101 }
08-02 04:39:38.231: D/dalvikvm(2642): GC_FOR_ALLOC freed 177K, 8% free 2964K/3192K, paused 21ms, total 24ms
08-02 04:39:38.321: D/AndroidRuntime(2642): Shutting down VM
08-02 04:39:38.321: W/dalvikvm(2642): threadid=1: thread exiting with uncaught exception (group=0xb1cd3b20)
08-02 04:39:38.331: E/AndroidRuntime(2642): FATAL EXCEPTION: main
08-02 04:39:38.331: E/AndroidRuntime(2642): Process: com.finecalc.ltafinecalculator, PID: 2642
08-02 04:39:38.331: E/AndroidRuntime(2642): android.os.NetworkOnMainThreadException
08-02 04:39:38.331: E/AndroidRuntime(2642): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145)
08-02 04:39:38.331: E/AndroidRuntime(2642): at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)
08-02 04:39:38.331: E/AndroidRuntime(2642): at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
08-02 04:39:38.331: E/AndroidRuntime(2642): at libcore.io.IoBridge.connect(IoBridge.java:112)
08-02 04:39:38.331: E/AndroidRuntime(2642): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
08-02 04:39:38.331: E/AndroidRuntime(2642): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
08-02 04:39:38.331: E/AndroidRuntime(2642): at java.net.Socket.connect(Socket.java:843)
08-02 04:39:38.331: E/AndroidRuntime(2642): at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
08-02 04:39:38.331: E/AndroidRuntime(2642): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
08-02 04:39:38.331: E/AndroidRuntime(2642): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
08-02 04:39:38.331: E/AndroidRuntime(2642): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
08-02 04:39:38.331: E/AndroidRuntime(2642): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
08-02 04:39:38.331: E/AndroidRuntime(2642): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
08-02 04:39:38.331: E/AndroidRuntime(2642): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
08-02 04:39:38.331: E/AndroidRuntime(2642): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
08-02 04:39:38.331: E/AndroidRuntime(2642): at com.finecalc.library.JSONParser.getJSONFromUrl(JSONParser.java:41)
08-02 04:39:38.331: E/AndroidRuntime(2642): at com.finecalc.library.UserFunctions.loginUser(UserFunctions.java:42)
08-02 04:39:38.331: E/AndroidRuntime(2642): at com.finecalc.ltafinecalculator.UserLogin$1.onClick(UserLogin.java:57)
08-02 04:39:38.331: E/AndroidRuntime(2642): at android.view.View.performClick(View.java:4438)
08-02 04:39:38.331: E/AndroidRuntime(2642): at android.view.View$PerformClick.run(View.java:18422)
08-02 04:39:38.331: E/AndroidRuntime(2642): at android.os.Handler.handleCallback(Handler.java:733)
08-02 04:39:38.331: E/AndroidRuntime(2642): at android.os.Handler.dispatchMessage(Handler.java:95)
08-02 04:39:38.331: E/AndroidRuntime(2642): at android.os.Looper.loop(Looper.java:136)
08-02 04:39:38.331: E/AndroidRuntime(2642): at android.app.ActivityThread.main(ActivityThread.java:5017)
08-02 04:39:38.331: E/AndroidRuntime(2642): at java.lang.reflect.Method.invokeNative(Native Method)
08-02 04:39:38.331: E/AndroidRuntime(2642): at java.lang.reflect.Method.invoke(Method.java:515)
08-02 04:39:38.331: E/AndroidRuntime(2642): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
08-02 04:39:38.331: E/AndroidRuntime(2642): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
08-02 04:39:38.331: E/AndroidRuntime(2642): at dalvik.system.NativeStart.main(Native Method)
08-02 04:39:41.111: D/(2670): HostConnection::get() New Host Connection established 0xb97a3cc0, tid 2670
08-02 04:39:41.181: W/EGL_emulation(2670): eglSurfaceAttrib not implemented
08-02 04:39:41.181: D/OpenGLRenderer(2670): Enabling debug mode 0
08-02 04:39:45.771: W/EGL_emulation(2670): eglSurfaceAttrib not implemented
08-02 04:39:48.371: W/EGL_emulation(2670): eglSurfaceAttrib not implemented
08-02 04:39:50.971: D/dalvikvm(2670): GC_FOR_ALLOC freed 123K, 6% free 3018K/3192K, paused 28ms, total 32ms
08-02 04:39:51.581: W/EGL_emulation(2670): eglSurfaceAttrib not implemented
08-02 04:39:51.811: D/dalvikvm(2670): GC_FOR_ALLOC freed 152K, 6% free 3380K/3584K, paused 22ms, total 31ms
08-02 04:40:18.351: W/EGL_emulation(2670): eglSurfaceAttrib not implemented
08-02 04:40:21.741: W/EGL_emulation(2670): eglSurfaceAttrib not implemented
08-02 04:40:23.021: D/AndroidRuntime(2670): Shutting down VM
08-02 04:40:23.021: W/dalvikvm(2670): threadid=1: thread exiting with uncaught exception (group=0xb1cd3b20)
08-02 04:40:23.031: E/AndroidRuntime(2670): FATAL EXCEPTION: main
08-02 04:40:23.031: E/AndroidRuntime(2670): Process: com.finecalc.ltafinecalculator, PID: 2670
08-02 04:40:23.031: E/AndroidRuntime(2670): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.finecalc.ltafinecalculator/com.finecalc.ltafinecalculator.UserRegister}: java.lang.NullPointerException
08-02 04:40:23.031: E/AndroidRuntime(2670): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
08-02 04:40:23.031: E/AndroidRuntime(2670): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
08-02 04:40:23.031: E/AndroidRuntime(2670): at android.app.ActivityThread.access$800(ActivityThread.java:135)
08-02 04:40:23.031: E/AndroidRuntime(2670): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
08-02 04:40:23.031: E/AndroidRuntime(2670): at android.os.Handler.dispatchMessage(Handler.java:102)
08-02 04:40:23.031: E/AndroidRuntime(2670): at android.os.Looper.loop(Looper.java:136)
08-02 04:40:23.031: E/AndroidRuntime(2670): at android.app.ActivityThread.main(ActivityThread.java:5017)
08-02 04:40:23.031: E/AndroidRuntime(2670): at java.lang.reflect.Method.invokeNative(Native Method)
08-02 04:40:23.031: E/AndroidRuntime(2670): at java.lang.reflect.Method.invoke(Method.java:515)
08-02 04:40:23.031: E/AndroidRuntime(2670): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
08-02 04:40:23.031: E/AndroidRuntime(2670): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
08-02 04:40:23.031: E/AndroidRuntime(2670): at dalvik.system.NativeStart.main(Native Method)
08-02 04:40:23.031: E/AndroidRuntime(2670): Caused by: java.lang.NullPointerException
08-02 04:40:23.031: E/AndroidRuntime(2670): at com.finecalc.ltafinecalculator.UserRegister.onCreate(UserRegister.java:26)
08-02 04:40:23.031: E/AndroidRuntime(2670): at android.app.Activity.performCreate(Activity.java:5231)
08-02 04:40:23.031: E/AndroidRuntime(2670): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-02 04:40:23.031: E/AndroidRuntime(2670): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
08-02 04:40:23.031: E/AndroidRuntime(2670): ... 11 more
最佳答案
当应用程序尝试在主线程中执行网络操作时会抛出此异常。在您的 onViewCreated 中使用以下代码来避免此错误,否则在线程或异步类中调用您的网络操作(从 Web 服务器获取数据)请求。
public void onViewCreated(View view, Bundle savedInstanceState)
{
int SDK_INT = android.os.Build.VERSION.SDK_INT;
if (SDK_INT > 8)
{
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
//your codes here
}
}
关于android-asynctask - android.os.NetworkOnMainThreadException at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java :1145),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25093546/
这个问题在这里已经有了答案: How can I fix 'android.os.NetworkOnMainThreadException'? (66 个回答) 关闭2年前。 我刚刚发现 Networ
这个问题在这里已经有了答案: How can I fix 'android.os.NetworkOnMainThreadException'? (65 个回答) 7年前关闭。 嗨,我正在尝试使用 an
这个问题已经有答案了: How can I fix 'android.os.NetworkOnMainThreadException'? (64 个回答) 已关闭 3 年前。 我在 Android 应
我的 Android 项目中有一个名为 EditTrip_Activity.java 的类/Activity ,并且我不断收到此 NetworkOnMainThreadException。我之前已经得
我试图从 MySQL 数据库获取产品的详细信息,但是当我编译代码时,即使我在调用 GetProductDetails 类来执行时将其用作 AsyncTask,也会收到 NetworkOnMainThr
这个问题已经有答案了: How can I fix 'android.os.NetworkOnMainThreadException'? (64 个回答) 已关闭 7 年前。 实际上,我尝试将图像文件
我想将视频(从图库中选择)上传到服务器(localhost-Wampserver 在我的计算机上运行 Apache 2.4.4)。从异常和搜索中,我发现网络操作不应该发生在UI运行的线程中。但我该怎么
我正在尝试将 Android 应用程序与 Twitter 连接,但我不知道这部分代码有什么问题: Thread thread = new Thread(){ @Override
为什么当我在 Android 4.0 版本中运行时,此错误通常出现在 listview 中,任何人都可以帮助我解决这个问题。我搜索了一些网站,发现像在 中使用 asynctask >url 我该如何实
在主线程上没有网络调用,但我仍然得到同样的错误:NetworkOnMainThreadException。 MainActivity.class: public class MainActivity
熟悉Android开发,习惯了在UIThread上进行网络调用时的NetworkOnMainThreadException异常。 但是在下面的情况下会抛出 IOException 而不会抛出 Netw
我了解到在 GUI 线程上不允许进行网络操作。对我来说还可以。但是为什么在 Dialog 按钮点击回调上使用这段代码仍然会产生 NetworkOnMainThreadException ? new T
我正在尝试使用套接字在 android 中编写一个服务器/客户端应用程序,并且我在 AsyncTask 中处理客户端套接字(服务器不是 android,只是普通的 java)。当我得到异常时我正在尝试
我已经通过所有 SO 的解决方案来解决 NetworkOnMainThreadException 包括 ASync 类 - 但仍然有问题 这是我的简单代码: ActivityMain 类: publi
这个问题已经有答案了: How can I fix 'android.os.NetworkOnMainThreadException'? (65 个回答) 已关闭 9 年前。 我开发了一个使用 and
我正在尝试通过启动 TCP 服务器来访问 android 网络。但是当我创建一个新线程时,要么 Thread t = new Thread(runnable); t.start(); 或FutureT
我尝试从 POST 请求中获取响应。问题是,尽管我正在使用 AsyncTask 进行网络通信,但有时我会得到 NetworkOnMainThreadException。这意味着有时我成功获得响应,有时
我按照此说明使用传感器模拟器在模拟器上调试我的应用程序: http://code.google.com/p/openintents/wiki/SensorSimulator#How_to_use_th
我在下面有一些代码: protected void testConnection(String url) { DefaultHttpClient httpclient = new Defaul
我的应用程序中有一些网络请求,每当调用网络相关代码时,我都会收到此异常。我已经把它们放在后台了: @Background protected void getBitmapFromURL
我是一名优秀的程序员,十分优秀!