Cannot resolve symbol HttpGet,HttpClient,HttpResponce in Android Studio
Try this code:
final String ERROR = "my error message....";
private class DownloadWebPageTask extends AsyncTask<String, Void, String> {
// some code and method ..... see AsyncTask
@Override
protected String doInBackground(String... urls) {
URL urlL = null;
try {
urlL = new URL(url);//"//chmi.cz..../"
HttpURLConnection urlConnection = null;
try {
urlConnection = (HttpURLConnection) urlL.openConnection();
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
response = readStream(in);
return response;
} catch (IOException e) {
//throw new RuntimeException(e);
} finally {
if(urlConnection != null)
urlConnection.disconnect();
return ERROR;
}
} catch (MalformedURLException e) {
e.printStackTrace();
return ERROR;
}
}
return response;
}
private String readStream(InputStream is) {
try {
ByteArrayOutputStream bo = new ByteArrayOutputStream();
int i = is.read();
while(i != -1) {
bo.write(i);
i = is.read();
}
return bo.toString();
} catch (IOException e) {
return "";
}
}
396LW NO topic_id
AD
Další témata ....(Topics)
Try:
- close Eclipse and continue updating
or
- change permission of folder
or
- disable antivirus
or
- copy manually from zip packages from temp
c:\Program Files\android\sdk\temp\
c:\Program Files\android\sdk\temp\platform-tools_r19.0.1-windows.zip
c:\Program Files\android\sdk\temp\tools_r22.6.2-windows.zip
into propriety folders
or
- download all SDK package and replace old
https://developer.android.com/sdk/index.html?hl=sk
- close Eclipse and continue updating
or
- change permission of folder
or
- disable antivirus
or
- copy manually from zip packages from temp
c:\Program Files\android\sdk\temp\
c:\Program Files\android\sdk\temp\platform-tools_r19.0.1-windows.zip
c:\Program Files\android\sdk\temp\tools_r22.6.2-windows.zip
into propriety folders
or
- download all SDK package and replace old
https://developer.android.com/sdk/index.html?hl=sk
Goto in for cycle Java example source code.
MainClass.java
MainClass.java
public class MainClass {
public static void main(String[] arg) {
String[] arrayOfString = {"nothing", "Hello", "people"
, "bye-bye", "hello", "world!", "end" };
OuterLoop: for (int i = 0;i<6; i++) {
for (int j = 0; j < arrayOfString.length; j++) {
if (arrayOfString[j].equals("world!")) {
continue OuterLoop; // as goto from Csharp, or C/C++
}
System.out.println(arrayOfString[j]);
System.out.println(i);
if (i == 1) {
System.out.println("break");
break OuterLoop;
}
}
}
}
}
/*
nothing
0
Hello
0
people
0
bye-bye
0
hello
0
nothing
1
break
*/
Emulator window was out of view and was recentred
Emulator] WARNING: Data partition already in use. Changes will not persist!
Emulator] WARNING: SD Card image already in use: C:\Documents and Settings\user_name\.android\avd\hvga21_up1_7.avd/sdcard.img
Emulator] WARNING: Cache partition already in use. Changes will not persist!
Basic step
Try restart Eclipse if using from menu File->Restart
Other solutions
Solution 1: try restart ADB server
//android.okhelp.cz/how-quickly-restart-adb-exe-adb-server-android-emulator-example/
Solution 2:
//android.okhelp.cz/android-emulator-wont-run-application-started-from-eclipse/
Solution 3:
Try delete:
Try solution 4:
Eclipse menu select Window->Preferences->Android
Windows 32
FROM: C:\Program Files\Android\android-sdk
TO: C:\PROGRA~1\Android\android-sdk
Windows 64
FROM: C:\Program Files (x86)\Android\android-sdk
TO: C:\PROGRA~2\Android\android-sdk
Emulator] WARNING: Data partition already in use. Changes will not persist!
Emulator] WARNING: SD Card image already in use: C:\Documents and Settings\user_name\.android\avd\hvga21_up1_7.avd/sdcard.img
Emulator] WARNING: Cache partition already in use. Changes will not persist!
Basic step
Try restart Eclipse if using from menu File->Restart
Other solutions
Solution 1: try restart ADB server
//android.okhelp.cz/how-quickly-restart-adb-exe-adb-server-android-emulator-example/
Solution 2:
Delete Run Configuration
//android.okhelp.cz/android-emulator-wont-run-application-started-from-eclipse/
Solution 3:
Try delete:
c:\Documents and Settings\user_name\.android\avd\my_avd.avd\cache.img
c:\Documents and Settings\user_name\.android\avd\my_avd.avd\userdata-qemu.img
Try solution 4:
Eclipse menu select Window->Preferences->Android
Windows 32
FROM: C:\Program Files\Android\android-sdk
TO: C:\PROGRA~1\Android\android-sdk
Windows 64
FROM: C:\Program Files (x86)\Android\android-sdk
TO: C:\PROGRA~2\Android\android-sdk
Black and white bitmap image pictures, gray scale colormatrix Android example.
public class ApokusActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new SampleView(this));
}
private static class SampleView extends View {
// CONSTRUCTOR
public SampleView(Context context) {
super(context);
setFocusable(true);
}
@Override
protected void onDraw(Canvas canvas) {
Paint paint = new Paint();
canvas.drawColor(Color.YELLOW);
// you need to insert a image flower_blue into res/drawable folder
paint.setFilterBitmap(true);
Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),
R.drawable.flower_blue);
canvas.drawBitmap(bitmapOrg, 10, 10, paint);
int width, height;
ColorMatrix cm = new ColorMatrix(
new float[]{
0.5f,0.5f,0.5f,0,0,
0.5f,0.5f,0.5f,0,0,
0.5f,0.5f,0.5f,0,0,
0,0,0,1,0,0,
0,0,0,0,1,0
});
cm.setSaturation(0);
ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
paint.setColorFilter(f);
int h = bitmapOrg.getHeight();
//canvas.drawBitmap(bitmapOrg, 10, 10, paint);
canvas.drawBitmap(bitmapOrg, 10, 10 + h + 10, paint);
}
}
}
How include layout defined in other xml file into another xml file example:
res/layout/my_layout.xml into
main.xml
res/layout/my_layout.xml into
main.xml
<include layout="@layout/my_layout" android:id="@+id/idMyLayout" />
Editace: 2015-12-10 19:13:01
Počet článků v kategorii: 396
Url:cannot-resolve-symbol-httpgethttpclienthttpresponce-in-android-studio