[Solved] How to add numbers for arraylist

Just create a list and add items to it, List<Integer> checkedList = new ArrayList<Integer>(); for (Product p : boxAdapter.getBox()) { if (p.aBoolean) checkedList.add(p.id); } I would suggest you work on your basics before you start coding, it will help you in such situations. Hope this is the solution you were looking for. 0 solved How … Read more

[Solved] Android Qr code generation [closed]

Try this public void generateQRCode_general(String data, ImageView img)throws WriterException { com.google.zxing.Writer writer = new QRCodeWriter(); String finaldata = Uri.encode(data, characterEncoding); BitMatrix bm = writer.encode(finaldata, BarcodeFormat.QR_CODE,bitmapWidth, bitmapHeight); ImageBitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight,Config.ARGB_8888); for (int i = 0; i < bitmapWidth; i++) { for (int j = 0; j < bitmapHeight; j++) { ImageBitmap.setPixel(i, j, bm.get(i, j) ? … Read more

[Solved] What do I need to learn to code an app like Snapchat? [closed]

Well you can get started with the Camera API(updated to Camera2 API) and the CameraX API which will help you with photography on Android devices. Camera2API described here CameraAPI Documentation Video Recording Documentation CameraX Documentation Regarding storage, I suggest that you start with what is provided in the Google Documentation and work your way up … Read more

[Solved] Code does not wait for FirebaseDatabase to be read

As Selvin commented: data is loaded from Firebase asynchronously. You can’t reliably wait for the data to become available. See Setting Singleton property value in Firebase Listener. The solution is to move the code that needs the data from Firebase into the onDataChange in checkDataNew: fun checkDataNew() { var rootRef=FirebaseDatabase.getInstance().getReference(“BG Data”) // Read from the … Read more

[Solved] I get NetworkOnMainThreadExeption when using kevinsawickis http-request class [duplicate]

Perform the same in this private class LongOperation extends AsyncTask<String, Void, String> { @Override protected String doInBackground(String… params) { String response = HttpRequest.get(“http://google.com”).body(); System.out.println(“Response was: ” + response); return response ; } @Override protected void onPostExecute(String result) { } @Override protected void onPreExecute() {} @Override protected void onProgressUpdate(Void… values) {} } Start it in your … Read more

[Solved] Android listview array out of bounds

Try this, you have to pass in your Adapter and call notifyDataSetChanged on it after you clear the list. @Override protected void onPreExecute() { super.onPreExecute(); postList.clear(); yourAdapter.notifyDataSetChanged(); } Edit: Alternative way private class LoadMoreDataTask extends AsyncTask<Void, Void, List<PostRow>>{ @Override protected void onPreExecute() { super.onPreExecute(); //postList.clear(); //do not clear } @Override protected List<PostRow> doInBackground(Void… params) { … Read more

[Solved] android ImageView allways top and bottom [closed]

Try this layout. <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:layout_width=”fill_parent” android:layout_height=”fill_parent”> <ImageView android:id=”@+id/imageView” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignParentEnd=”true” android:layout_alignParentStart=”true” android:layout_alignParentTop=”true” android:src=”https://stackoverflow.com/questions/38821397/@mipmap/ic_launcher” /> <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_centerHorizontal=”true” android:orientation=”horizontal” android:layout_above=”@+id/imageView2″ android:layout_below=”@+id/imageView”></LinearLayout> <ImageView android:id=”@+id/imageView2″ android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:src=”https://stackoverflow.com/questions/38821397/@mipmap/ic_launcher” android:layout_alignParentEnd=”true” android:layout_alignParentStart=”true” android:layout_alignParentBottom=”true” /> </RelativeLayout> solved android ImageView allways top and bottom [closed]

[Solved] Android Saving JSON response in Sharedpreferences

Use this class for your purpose with files ! Hope it will help you ! public class MyJSON { static String fileName = “myBlog.json”; public static void saveData(Context context, String mJsonResponse) { try { FileWriter file = new FileWriter(context.getFilesDir().getPath() + “https://stackoverflow.com/” + fileName); file.write(mJsonResponse); file.flush(); file.close(); } catch (IOException e) { Log.e(“TAG”, “Error in Writing: … Read more

[Solved] Getting IndexOutOfBound Android

In here: if (singleUserData.size() == 1) you seem to be checking that the size is of 1 element. But within that same scope, you are accessing multiple items. You would probably need to change this check: if (singleUserData.size() == 1) to if (singleUserData.size() == 5). 4 solved Getting IndexOutOfBound Android

[Solved] Control an application from a service

For the Service -> Activity communication you can use LocalBroadcastManager, check this SO answer: Android update activity UI from service For the Activity -> Service communication you either start service and add extras to intent or have a bound service. Make sure you read this article: http://developer.android.com/guide/components/services.html 1 solved Control an application from a service

[Solved] How to put a border in an EditText? [duplicate]

just try this one, first create one XML file, inside drawable folder (use new drawable xml) and add this lines <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android” android:shape=”rectangle”/> <solid android:color=”#000000″/> <stroke android:color=”#ffffff” android:width=”05dp”/> <corners android:radius=”20dp”/> then add this line inside Your edittext property android:background=”@drawable/(file_name)” i don’t know what your expecting, maybe it will help you solved How … Read more