So I've recently implemented a variation of the dirty_c0w exploit on a Nexus 6P running Nougat 7.0 (NBD90X to be specific) using the radare2 method. I'm not sure I totally grasp the concept of r2 though and I was wondering if anybody here knew much about the topic? Maybe my question is a little vague and I apologize if this is the case, this is the first time I've ever asked anything here so bear with me.

super noob here. I finished my first python program and it works exactly like its intended. Its a simple search engine for a small databse. Now im trying to port it as an android APP with Kivy. What i want to do now is simply display the content of my entire sqlite database (20 rows or so) from a function that works well in the original software.

In the android app, the function list_table seems to work cause it does display the 'printed text', but not the element of the database themselves. Basically it only prints " MVA: " .Im really not sure why. Ive been trying for a while to find a solution but im stuck :/

Thanks for your help folks.

#This is my main.py file

from kivy.app import App
import sqlite3 as lite
import sys
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.anchorlayout import AnchorLayout
from kivy.core.window import Window
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout


import time



Window.clearcolor = (1, 1, 1, 1)

class SearchWidget(BoxLayout):
    def list_table(self, *args):
        try:
            con = lite.connect('data.db')
            con.text_factory = str
            cur = con.cursor()

            cur.execute("SELECT * FROM mva ORDER BY mva ASC")
            con.commit()
            ar = cur.fetchall()

            for item in ar:
                data = 'MVA ' + str(item[1]) + str(item[2]) + ': ' +      str(item[0])  + ' ' + str(item[3])

            return data

    except lite.Error, e:

        if con:
            con.rollback()

        print "Error %s:" % e.args[0]
        sys.exit(1)

    finally:

        if con:
            con.close()


class MyApp(App):

    def build(self):

        return SearchWidget()

if __name__ == '__main__':
      MyApp().run()

And this is my my.kv file

<SearchWidget>:
    orientation: 'vertical'
    TextInput:
        id: my_textinput
        font_size: 25
        size_hint_y: None
        height: 100
        text: 'MVA Search'

    BoxLayout:
        Label:
            color: (0, 0, 0, 1)
            size: self.texture_size
            text: root.list_table()
            font_size: 25

I'm developing home budget app. In this, I had two tables in database. One table for income and another one for expenses. In the Expense table, i have three column to get data from user that is, expense amt, category, date. I'm using Date Picker to get date from user and I have saved user entered date into database expense table.

I need to display data according to month. Let say now we are in December i need to display all transaction of December. How can i achieve this?

I am beginner in all this but i watched many tutorials and implemented this, but my app is not able to move ball over a fixed path so i need help in it...

MainActivity.java

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(new GamePanel(this));
    }

GamePanel.java

public class GamePanel extends View {
    static int x,y,BALL1_X,BALL1_Y,BALL2_X,BALL2_Y;
    Path path1,path2;
    RectF rect1,rect2;
    private ShapeDrawable drawable;
    private Paint paint1 = new Paint();
    private Paint paint2 = new Paint();
    private Paint paint = new Paint();


    public GamePanel(Context context) {
        super(context);
      /*  x = 10;
        y = 10;
        int width = 300;
        int height = 50;*/

        drawable = new ShapeDrawable(new RectShape());
        drawable.getPaint().setColor(Color.BLUE);
        drawable.setBounds(30,30,450,450);

        BALL1_X=BALL1_Y=30;
        BALL2_X=450 ;
        BALL2_Y=30;

        paint.setColor(Color.RED);
        paint.setStyle(Paint.Style.STROKE);

        // create the Paint and set its color
        //1st circle
       /* paint1 = new Paint();
        paint1.setColor(Color.GRAY);*/
        rect1 = new RectF(50, 50, BALL1_X, BALL1_Y);
        paint1 = new Paint(Paint.FILTER_BITMAP_FLAG);
        paint1.setStyle(Paint.Style.FILL);
        paint1.setColor(Color.GRAY);
        //paint1.setStrokeWidth(30);
        //2nd circle
        /*paint2 = new Paint();
        paint2.setColor(Color.BLACK);*/
        rect2 = new RectF(50, 50, BALL2_X, BALL2_Y);
        paint2 = new Paint(Paint.FILTER_BITMAP_FLAG);
        paint2.setStyle(Paint.Style.FILL);
        paint2.setColor(Color.BLACK);

        path1 = new Path();
        path2 = new Path();
      //  path.moveTo(BALL1_X,BALL1_Y);
      //  path.lineTo(100,200);
      //  path.lineTo(200,100);
        /*while(BALL1_X != BALL2_X)
        {
            path.lineTo(BALL1_X,BALL1_Y);
            BALL1_X++;
            BALL2_Y++;
        }*/
        //path.moveTo(360, 360);
        //path.addArc(rect2, 360, 360);
        //setBackgroundColor(Color.WHITE);

    }

    @Override
    public void onDraw(Canvas canvas)
    {
        drawable.draw(canvas);
       // x=getWidth();
       // y=getHeight();
        canvas.drawColor(Color.TRANSPARENT);
        canvas.drawCircle(30,30,25,paint1);
        move1(30,30,450,450);
        canvas.drawPath(path1,paint);
      //  canvas.drawPath(path,paint);
        canvas.drawCircle(450,30,25,paint2);
        move2(450,30,30,450);
        canvas.drawPath(path2,paint);
        motion(10);
        invalidate();

        // move(10);
    }

    public void move1(int x1,int y1, int x2, int y2)
    {
        path1.moveTo(x1,y1);
        path1.lineTo(x2,y2);
        //path1.close();
    }

    public void move2(int x1,int y1, int x2, int y2)
    {
        path2.moveTo(x1,y1);
        path2.lineTo(x2,y2);
    }

    public void motion(int speed)
    {

        if(BALL1_X==30 && BALL1_Y==30)
        {
            BALL1_X+=speed;
            BALL1_Y+=speed;
        }
        if(BALL1_X<450 && BALL1_Y<450)
        {
            BALL1_X+=speed;
            BALL1_Y+=speed;
        }
     /* for(BALL1_X=30;BALL1_X<=450;BALL1_X++)
      {
          for(BALL1_Y=30;BALL1_Y<=450;BALL1_Y++)
          {
            //  if(BALL1_X==BALL1_Y)
              {*/
                 // BALL1_X+=speed;
                  //BALL1_Y+=speed;
             // }
          //}
      }
        /*
        //   while(BALL1_X!=BALL2_X && BALL1_Y!=BALL2_Y)
       // {
            if(BALL1_X==30 || BALL1_Y<=450)
            {
                BALL1_X+=speed;
                BALL1_Y+=speed;
            }

            if(BALL2_X==450 || BALL2_Y>=30)
            {
                BALL2_X-=speed;
                BALL2_Y+=speed;
            }
         */
    }
    //}
//}

Please help me with this... Thank You

hii im uploading image from android device to my web serverbut when im trying to change the current ftp working directory to the another one,im getting a exception saying "it.sauronsoftware.ftp4j.FTPException [code=550, message= Can't change directory to /Events: No such file or directory]" I have also changed chmod to 777 but problem still raises. Please help to solve this thank you

Realm recyclerview in following address: realmrecyclerview has the loadmore feature and there is a example project which creates a 60 realm object then query realm and set the results of the query to recyclerview's adapter. after scrolling the recyclerview to end onloadmore listner get fired in loadmore function another async method get called which creates 60 more object and save to realm, then recyclerview shows the new objects. I want to use this loadmore functionality to paginate the big dataset query.I tried to query in the onloadmore function but the adapter did not refereshed with new query results. but when I recreated the adapter and set to recyclerview it was working.

This question already has an answer here:

My app gets book information from the Google Books API and reports books based on what the user types in. The problem is relating to the EditText textfield where the user types in the information.

How do you fix it?

XML (activity_main.xml):

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.android.booklisting.MainActivity">

<EditText
    android:id="@+id/search"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:hint="@string/search_hint"
    android:inputType="text"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginLeft="10dp"
    android:layout_marginStart="10dp"
    android:layout_marginTop="10dp" />

<Button
    android:id="@+id/search_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/search"
    android:text="@string/get_books"/>

Java (PerformingNetworkRequest.java):

public class PerformingNetworkRequest extends AppCompatActivity {

String dataUrl;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.book_list);
    EditText searchBox = (EditText) findViewById(R.id.search);
    String searchQuery = searchBox.getText().toString();
    dataUrl = "https://www.googleapis.com/books/v1/volumes?q="+ searchQuery + "&maxResults=5";
    BookAdapter b = new BookAdapter(this, books);
    ListView l = (ListView) findViewById(R.id.book_list);
    l.setAdapter(b);
}
private class DownloadFilesTask extends AsyncTask<String, Void, List<Book>> {
    @Override
    protected List<Book> doInBackground(String... params) {
        return Network.getBookData(params[0]);
    }
}
List<Book> books = new DownloadFilesTask().doInBackground(dataUrl);

}

I posted an Android app that has 3 mediated networks by Heyzap; let's call this version 1.0. I'd like to add another ad network in a subsequent version (version 1.1 of the app). When I do this, however, version 1.1 supports 4 mediated networks while version 1.0 supports only 3. Is this ok? Will version 1.0 run as expected or will it crash because it doesn't support the 4th ad network?

I tried looking through Heyzap's documentation and scoured the internet for some insight, but could find none. And, this is something I don't know how to test without disrupting what I currently have in production or by polluting my Heyzap profile with defunct networks. Any info on this would be greatly appreciated.

My eddystone beacon application was perfectly working on Android 5.0 but after updating to Android 6.0.1 it is not scanning at all. Whereas same app is working on another phone having 5.0 version.

I have search on internet, found that there were some issue with BLE in Android 6.0. Also I followed some suggested fixes like turning on Location to get BLE scanning work or force to use old 4.x Bluetooth API instead of 5.x API beaconManager.setAndroidLScanningDisabled(true);

But these wont help to get scanning in my case.

Its very appreciable if someone help me.

i wanted to take screenshot of layout1 on button click and then set on the screeenshot in a imageview to check which screenshot it is saving

but it is showing the screenshot of the whole screen

heres why xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
android:background="@color/colorPrimaryDark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:id="@+id/content"
tools:context="com.example.apple.screenshot.MainActivity">



   <Button
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:background="#ff00ff"
   android:text="capture"
   android:id="@+id/action"
   />

//this is the layout to be capture

   <RelativeLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_below="@id/action"
   android:background="#000"
   android:id="@+id/layout1">
      <Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="#ff00ff"
      android:text="layout to be capture "
      android:id="@+id/actio"
      />
   </RelativeLayout>

//this is imageview on which the capture screenshot will be shown //just for testing purpose

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/action">

 <ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/set"

    />
   </RelativeLayout>
    </RelativeLayout>

this is my java file

  Button press, share;
    ImageView set;
    public static File imagePath;
    RelativeLayout layout;

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);



  layout=(RelativeLayout)findViewById(R.id.layout1);
      final view   ViewrootView=getWindow().getDecorView().findViewById(R.id.layout1);

    press = (Button) findViewById(R.id.action);
    set = (ImageView) findViewById(R.id.set);
    press.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
           Bitmap bit = takeScreenshot();
           set.setImageBitmap(bit);

}

public Bitmap takeScreenshot() {
    View rootView = findViewById(R.id.layout1).getRootView();
    rootView.setDrawingCacheEnabled(true);
    return rootView.getDrawingCache();
}

}

how to fetch first image without click fetch image button

click to view image

this code work fine but on click fetch image button but i want fetch image with out click fetch images button i want to remove this button

Public class MainActivity extends AppCompatActivity implements View.OnClickListener {

private String imagesJSON;

private static final String JSON_ARRAY ="result";

private static final String IMAGE_URL = "url";

private JSONArray arrayImages= null;

private int TRACK = 0;

private static final String IMAGES_URL = "http://www.simplifiedcoding.16mb.com/ImageUpload/getAllImages.php";

private Button buttonFetchImages;
private Button buttonMoveNext;
private Button buttonMovePrevious;
private ImageView imageView;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    imageView = (ImageView) findViewById(R.id.imageView);
    buttonFetchImages = (Button) findViewById(R.id.buttonFetchImages);
    buttonMoveNext = (Button) findViewById(R.id.buttonNext);
    buttonMovePrevious = (Button) findViewById(R.id.buttonPrev);
    buttonFetchImages.setOnClickListener(this);
    buttonMoveNext.setOnClickListener(this);
    buttonMovePrevious.setOnClickListener(this);
}


private void extractJSON(){
    try {
        JSONObject jsonObject = new JSONObject(imagesJSON);
        arrayImages = jsonObject.getJSONArray(JSON_ARRAY);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

private void showImage(){
    try {
        JSONObject jsonObject = arrayImages.getJSONObject(TRACK);
        getImage(jsonObject.getString(IMAGE_URL));
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

private void moveNext(){
    if(TRACK < arrayImages.length()){
        TRACK++;
        showImage();
    }
}

private void movePrevious(){
    if(TRACK>0){
        TRACK--;
        showImage();
    }
}



private void getAllImages() {
    class GetAllImages extends AsyncTask<String,Void,String>{
        ProgressDialog loading;
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            loading = ProgressDialog.show(MainActivity.this, "Fetching Data...","Please Wait...",true,true);
        }

        @Override
        protected void onPostExecute(String s) {
            super.onPostExecute(s);
            loading.dismiss();
            imagesJSON = s;
            extractJSON();
            showImage();
        }

        @Override
        protected String doInBackground(String... params) {
            String uri = params[0];
            BufferedReader bufferedReader = null;
            try {
                URL url = new URL(uri);
                HttpURLConnection con = (HttpURLConnection) url.openConnection();
                StringBuilder sb = new StringBuilder();

                bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream()));

                String json;
                while((json = bufferedReader.readLine())!= null){
                    sb.append(json+"\n");
                }

                return sb.toString().trim();

            }catch(Exception e){
                return null;
            }
        }
    }
    GetAllImages gai = new GetAllImages();
    gai.execute(IMAGES_URL);
}

private void getImage(String urlToImage){
    class GetImage extends AsyncTask<String,Void,Bitmap>{
        ProgressDialog loading;
        @Override
        protected Bitmap doInBackground(String... params) {
            URL url = null;
            Bitmap image = null;

            String urlToImage = params[0];
            try {
                url = new URL(urlToImage);
                image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return image;
        }

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            loading = ProgressDialog.show(MainActivity.this,"Downloading Image...","Please wait...",true,true);
        }

        @Override
        protected void onPostExecute(Bitmap bitmap) {
            super.onPostExecute(bitmap);
            loading.dismiss();
            imageView.setImageBitmap(bitmap);
        }
    }
    GetImage gi = new GetImage();
    gi.execute(urlToImage);
}

@Override
public void onClick(View v) {
    if(v == buttonFetchImages) {
        getAllImages();
    }
    if(v == buttonMoveNext){
        moveNext();
    }
    if(v== buttonMovePrevious){
        movePrevious();
    }
}

}

My old code was only working well till lolipop. i tried to write a new one but its not working in marshmallow either. I been sitting on this for the last two days and i dont have a clue :(.

public void share(View view){
niv1 = (NetworkImageView) findViewById(R.id.imgNetwork);
File file = getLocalBitmapFile(niv1);
Uri bmpUrii = FileProvider.getUriForFile(this, "com.myfileprovider", file);
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/*");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUrii);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "share");
shareIntent.putExtra(Intent.EXTRA_TEXT, Datas.Address);
startActivity(Intent.createChooser(shareIntent, "Share Image"));
    } 

public File getLocalBitmapFile(NetworkImageView imageView) {

Drawable drawable = imageView.getDrawable();
Bitmap bmp = null;
if (drawable instanceof BitmapDrawable) {
    bmp = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
} else {
    return null;
}
File bmpUri = null;

    File file = new File(Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_DOWNLOADS), "share_image_" + System.currentTimeMillis() + ".png");
    file.getParentFile().mkdirs();
FileOutputStream out = null;
try {
    out = new FileOutputStream(file);
} catch (FileNotFoundException e) {
    e.printStackTrace();
}
bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
try {
    out.close();
} catch (IOException e) {
    e.printStackTrace();
}
return file;
}

What I want is, When the RelativeLayout press state is active, I want the layout alpha to be 50% and when its not I need 100% alpha.

The following code doesn't seem to be working.

if (relativelayout.hasFocus()){
    relativelayout.setAlpha(0.5f);
}

I tried setting the background of the relative layout to this

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true"
        android:drawable="@drawable/drawer_list_pressed" />

    <item android:state_focused="false"
        android:drawable="@drawable/drawer_list_normal" />

    <item android:state_selected="true"
        android:drawable="@drawable/drawer_list_pressed" />

</selector>

It is working on changing the background but not alpha of the contents.

I recently completed a C project that uses GTK and OpenSSL. I have native binaries in linux and they run just great. However my new goal is to make as close to native as I can with a build for windows.

I've tried MinGW and it produces as a exe, however it crashes very easily, and gdb performs poorly when attempting to debug windows builds. It's almost pointless to try to make sense of the binary mess.

So I'm in search of any alternative solutions or perhaps an improved version of this one. How do I build a Linux C project on windows?

Am a beginner to MVC web apps. How can i make my Form responsive? I want to write codes that will be used to make my form in mvc work logically but I do not know how , i have tried several means but failed.

Basically I want to append from an array a “new” player if the user scores for example 10+

I added an if statement for this.

The problem is it appends a new copy of the player each time. So if I score 10+ each new game it will keep creating duplicates of that player.

I want to add that new player only once if the user score 10+. After that no matter how many times the user scores 10+ it will not append the array again.

Here is my code below.

My Player Class

class PlayerManager {

static let instance = PlayerManager()

private init() {}

var playerIndex = Int(0)
var players = ["monkeyhero", "boyhero"]


func incrementIndex() {
    playerIndex += 1

    if playerIndex == players.count {

        playerIndex = 0
    }
}

func addGreyCat() {

    players.append("greyCat")

}
func getPlayer() -> String {
    return players[playerIndex]
} 

Now in the GameOverScene I add an if statement

        if 1 ... 2 ~= score {

        PlayerManager.instance.addGreyCat()
    }

And I also tried to save the "new" player by adding this code in the PlayerManager Class then adding in the if statement.

    func setNewPlayer(players: Array<Any>) {

    UserDefaults.standard.set(players, forKey: "NewPlayer")
}

func getNewPlayer() -> Array<Any> {

    return UserDefaults.standard.array(forKey: "NewPlayer")!
}

I have a UITableView that generates a random amount of sliders between the values of 1 and 5. If there are 3 sliders generated, there will be 3 rows with one slider in each row.

The maximum value of each slider is 100, and the minimum is 1. Based on the number of sliders will give the current value (e.g. 3 sliders means each slider will start with a value of 33 given I don't want the three sliders to exceed the amount of 100). How would I limit these sliders from exceeding the amount of 100 as a group?

Here's what I have so far:

Instance variable(s)

// Keeps track of the sum of all of the sliders values
var sliderValues = [Int]()

Within cellForRowAt indexPath: IndexPath):

cell.slider.addTarget(self, action: #selector(sliderChanged), for: .valueChanged)

Within sliderChanged(sender: UISlider):

func sliderChanged(sender: UISlider) {
    let sliderValue = Int(sender.value)

    // Gets the current cell in which the slider resides
    let cellPosition = sender.tag

    // Adds up the slider values
    let sum = sliderValues.reduce(0, +)

    if sum == 100 {
        // Prevent sliders from increasing their value
        print("limit reached")
    }

    // Update the sliders value with the appropriate slider based on the tag.
    sliderValues[cellPosition] = sliderValue
}

Any ideas?

I am working on a project where i have used tableView to list numbers and had to set the tableView height according to its content size and further i have disabled the scroll of tableview to satisfy my design. But the problem is when i have disabled it the bounce effect also got disabled.

Is there is any way to give it a bounce effect and at a time disabling the scroll?

It's easy to do that on windows(devmgmt.msc or registry) and linux(ethtool), but I have not idea when it comes to MacOS. Anyone knows that? thanks

Have you ever seen how Whatsapp and Facebook compress the pictures that you send or upload to it? This without loosing quality at all (apparently)!

I'm building an application that store camera pictures in a service, and I'd love to save the most space as possible.

I'm actually using this method that I saw here in StackOverflow:

  private String decodeFile(String path) {
        String strMyImagePath = null;
        Bitmap scaledBitmap = null;

        try {
            // Part 1: Decode image
            Bitmap unscaledBitmap = ScalingUtilities.decodeFile(path, 1000, 1200, ScalingUtilities.ScalingLogic.FIT);

            if (!(unscaledBitmap.getWidth() <= 800 && unscaledBitmap.getHeight() <= 800)) {
                // Part 2: Scale image
                scaledBitmap = ScalingUtilities.createScaledBitmap(unscaledBitmap, 1000, 1100, ScalingUtilities.ScalingLogic.FIT);
            } else {
                unscaledBitmap.recycle();
                return path;
            }

            // Store to tmp file

            BigInteger b = new BigInteger(35, new Random());

            String extr = Environment.getExternalStorageDirectory().toString();
            File mFolder = new File(extr + "/myTmpDir");
            if (!mFolder.exists()) {
                mFolder.mkdir();
            }

            String s = b.toString()+".png";

            File f = new File(mFolder.getAbsolutePath(), s);

            strMyImagePath = f.getAbsolutePath();
            FileOutputStream fos = null;
            try {
                fos = new FileOutputStream(f);
                scaledBitmap.compress(Bitmap.CompressFormat.PNG, 70, fos);
                fos.flush();
                fos.close();
            } catch (FileNotFoundException e) {

                e.printStackTrace();
            } catch (Exception e) {

                e.printStackTrace();
            }

            scaledBitmap.recycle();
        } catch (Throwable e) {
        }

        if (strMyImagePath == null) {
            return path;
        }
        return strMyImagePath;

    }

And the class ScalingUtilities (also here in StackOverflow):

public class ScalingUtilities {

    /**
     * Utility function for decoding an image resource. The decoded bitmap will
     * be optimized for further scaling to the requested destination dimensions
     * and scaling logic.
     *
     * @param res The resources object containing the image data
     * @param resId The resource id of the image data
     * @param dstWidth Width of destination area
     * @param dstHeight Height of destination area
     * @param scalingLogic Logic to use to avoid image stretching
     * @return Decoded bitmap
     */
    public static Bitmap decodeResource(Resources res, int resId, int dstWidth, int dstHeight,
                                        ScalingLogic scalingLogic) {
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeResource(res, resId, options);
        options.inJustDecodeBounds = false;
        options.inSampleSize = calculateSampleSize(options.outWidth, options.outHeight, dstWidth,
                dstHeight, scalingLogic);
        Bitmap unscaledBitmap = BitmapFactory.decodeResource(res, resId, options);

        return unscaledBitmap;
    }
    public static Bitmap decodeFile(String path, int dstWidth, int dstHeight,
                                    ScalingLogic scalingLogic) {
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(path, options);
        options.inJustDecodeBounds = false;
        options.inSampleSize = calculateSampleSize(options.outWidth, options.outHeight, dstWidth,
                dstHeight, scalingLogic);
        Bitmap unscaledBitmap = BitmapFactory.decodeFile(path, options);

        return unscaledBitmap;
    }

    /**
     * Utility function for creating a scaled version of an existing bitmap
     *
     * @param unscaledBitmap Bitmap to scale
     * @param dstWidth Wanted width of destination bitmap
     * @param dstHeight Wanted height of destination bitmap
     * @param scalingLogic Logic to use to avoid image stretching
     * @return New scaled bitmap object
     */
    public static Bitmap createScaledBitmap(Bitmap unscaledBitmap, int dstWidth, int dstHeight,
                                            ScalingLogic scalingLogic) {
        Rect srcRect = calculateSrcRect(unscaledBitmap.getWidth(), unscaledBitmap.getHeight(),
                dstWidth, dstHeight, scalingLogic);
        Rect dstRect = calculateDstRect(unscaledBitmap.getWidth(), unscaledBitmap.getHeight(),
                dstWidth, dstHeight, scalingLogic);
        Bitmap scaledBitmap = Bitmap.createBitmap(dstRect.width(), dstRect.height(),
                Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(scaledBitmap);
        canvas.drawBitmap(unscaledBitmap, srcRect, dstRect, new Paint(Paint.FILTER_BITMAP_FLAG));

        return scaledBitmap;
    }

    /**
     * ScalingLogic defines how scaling should be carried out if source and
     * destination image has different aspect ratio.
     *
     * CROP: Scales the image the minimum amount while making sure that at least
     * one of the two dimensions fit inside the requested destination area.
     * Parts of the source image will be cropped to realize this.
     *
     * FIT: Scales the image the minimum amount while making sure both
     * dimensions fit inside the requested destination area. The resulting
     * destination dimensions might be adjusted to a smaller size than
     * requested.
     */
    public static enum ScalingLogic {
        CROP, FIT
    }

    /**
     * Calculate optimal down-sampling factor given the dimensions of a source
     * image, the dimensions of a destination area and a scaling logic.
     *
     * @param srcWidth Width of source image
     * @param srcHeight Height of source image
     * @param dstWidth Width of destination area
     * @param dstHeight Height of destination area
     * @param scalingLogic Logic to use to avoid image stretching
     * @return Optimal down scaling sample size for decoding
     */
    public static int calculateSampleSize(int srcWidth, int srcHeight, int dstWidth, int dstHeight,
                                          ScalingLogic scalingLogic) {
        if (scalingLogic == ScalingLogic.FIT) {
            final float srcAspect = (float)srcWidth / (float)srcHeight;
            final float dstAspect = (float)dstWidth / (float)dstHeight;

            if (srcAspect > dstAspect) {
                return srcWidth / dstWidth;
            } else {
                return srcHeight / dstHeight;
            }
        } else {
            final float srcAspect = (float)srcWidth / (float)srcHeight;
            final float dstAspect = (float)dstWidth / (float)dstHeight;

            if (srcAspect > dstAspect) {
                return srcHeight / dstHeight;
            } else {
                return srcWidth / dstWidth;
            }
        }
    }

    /**
     * Calculates source rectangle for scaling bitmap
     *
     * @param srcWidth Width of source image
     * @param srcHeight Height of source image
     * @param dstWidth Width of destination area
     * @param dstHeight Height of destination area
     * @param scalingLogic Logic to use to avoid image stretching
     * @return Optimal source rectangle
     */
    public static Rect calculateSrcRect(int srcWidth, int srcHeight, int dstWidth, int dstHeight,
                                        ScalingLogic scalingLogic) {
        if (scalingLogic == ScalingLogic.CROP) {
            final float srcAspect = (float)srcWidth / (float)srcHeight;
            final float dstAspect = (float)dstWidth / (float)dstHeight;

            if (srcAspect > dstAspect) {
                final int srcRectWidth = (int)(srcHeight * dstAspect);
                final int srcRectLeft = (srcWidth - srcRectWidth) / 2;
                return new Rect(srcRectLeft, 0, srcRectLeft + srcRectWidth, srcHeight);
            } else {
                final int srcRectHeight = (int)(srcWidth / dstAspect);
                final int scrRectTop = (int)(srcHeight - srcRectHeight) / 2;
                return new Rect(0, scrRectTop, srcWidth, scrRectTop + srcRectHeight);
            }
        } else {
            return new Rect(0, 0, srcWidth, srcHeight);
        }
    }

    /**
     * Calculates destination rectangle for scaling bitmap
     *
     * @param srcWidth Width of source image
     * @param srcHeight Height of source image
     * @param dstWidth Width of destination area
     * @param dstHeight Height of destination area
     * @param scalingLogic Logic to use to avoid image stretching
     * @return Optimal destination rectangle
     */
    public static Rect calculateDstRect(int srcWidth, int srcHeight, int dstWidth, int dstHeight,
                                        ScalingLogic scalingLogic) {
        if (scalingLogic == ScalingLogic.FIT) {
            final float srcAspect = (float)srcWidth / (float)srcHeight;
            final float dstAspect = (float)dstWidth / (float)dstHeight;

            if (srcAspect > dstAspect) {
                return new Rect(0, 0, dstWidth, (int)(dstWidth / srcAspect));
            } else {
                return new Rect(0, 0, (int)(dstHeight * srcAspect), dstHeight);
            }
        } else {
            return new Rect(0, 0, dstWidth, dstHeight);
        }
    }

}

This is a cool way to compress images, but it compress it x5 approximately. As example I have a MotoG4 with 16Mpx, a standard picture weights 5MB, but this method and class compress it in a way that the picture weights 1MB-1.5MB, while I sent a 4.8MB picture trough whatsapp and it compressed it in 158kb!! Without loosing lots of quality.

Does anybody know a method to do that? Or what do I need to read to try to code something similar?

Greetings and good night! :)

I am working on a custom listView and within the array adapter I have tried code from other posts to have the soft keyboard disappear when the "Done" button on the soft keyboard is pressed. The problem is since (I think) I need to put the code in the custom adapter class and not in an Activity class where the other answers assume you are working in. Here is all my code.

MainActivity.java

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.app.Activity;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ViewSwitcher;

import java.util.ArrayList;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final ArrayList<String> Chores = new ArrayList<>();
        Chores.add("");
        //final String[] Chores = {"", "", ""};
        final ListAdapter MyAdapter = new CustomAdapter(this, Chores);
        ListView listViewObject = (ListView)findViewById(R.id.customListView_ID);
        listViewObject.setAdapter(MyAdapter);

        listViewObject.setOnItemClickListener(
            new AdapterView.OnItemClickListener(){
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id){
                    String ChoreString = String.valueOf(parent.getItemAtPosition(position));




                }
            }

        );
        final Button button = (Button) findViewById(R.id.button_ID);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Chores.add("");
                ((ArrayAdapter)MyAdapter).notifyDataSetChanged();

            }

        });




    }
}

CustomAdapter.java

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;


class CustomAdapter extends ArrayAdapter{

    public CustomAdapter(Context context, ArrayList choreText) {
        super(context, R.layout.custon_listview_row, choreText);
    }

    @NonNull
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater myInflater = LayoutInflater.from(getContext());
        View customView = myInflater.inflate(R.layout.custon_listview_row, parent, false);

        String singleListItem = (String) getItem(position);
        final TextView choreTextStatic = (TextView) customView.findViewById(R.id.textView_ID);
        final EditText choreTextEdit = (EditText) customView.findViewById(R.id.editText_ID);
        //set user input in editText field
        choreTextEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                boolean handled = false;
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    // TODO do something
                    choreTextStatic.setVisibility(View.VISIBLE);
                    choreTextEdit.setVisibility(View.INVISIBLE);

                    // This is where I am trying to make soft keyboard disapear

                    handled = true;
                }
                return handled;
            }
        });

        ImageButton imageButton = (ImageButton) customView.findViewById(R.id.imageButton_ID);

        choreTextEdit.setText(singleListItem, TextView.BufferType.EDITABLE);



        imageButton.setImageResource(R.drawable.clock);



        return customView;
    }
}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.emilythacker.chorelist.MainActivity">

    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/customListView_ID"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true"
        android:layout_marginTop="50dp" />

    <Button
        android:text="Add Chore"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true"
        android:id="@+id/button_ID" />
</RelativeLayout>

custom_listview_row.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:layout_height="60dp">

    <ImageButton
        android:layout_width="60dp"
        android:scaleType="fitCenter"
        app:srcCompat="@drawable/clock"
        android:id="@+id/imageButton_ID"
        android:layout_height="60dp"
        android:background="@null"
        android:layout_alignParentRight="true"
        android:padding="5dp"
        android:layout_weight="1" />



    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:id="@+id/editText_ID"
        android:layout_alignParentLeft="true"
        android:alpha = ".5"
        android:hint="Enter chore"
        android:maxLines="1"
        android:inputType="text"
        android:imeOptions="actionDone" />

    <TextView
        android:text="TextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:id="@+id/textView_ID"
        android:layout_alignBaseline="@+id/editText_ID"
        android:layout_alignBottom="@+id/editText_ID"
        android:layout_alignParentStart="true"
        android:visibility="invisible"
        android:imeOptions="actionDone"/>


</RelativeLayout>