So I have an app which uses a couple of very large SDKs (such as the Amazon AWS SDK). In order to circumvent the 64k method limit on the dex file, I run proguard on both prod and debug builds of the app for it to successfully compile.

The proguard file is below:

-keep class org.w3c.dom.bootstrap.** { *; }
-keep class org.joda.time.** { *; }
-keep class com.facebook.** { *; }
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-dontwarn org.codehaus.jackson.map.ext.**

The app runs fine, and I can use Android Studio's built in debugger in order to add break points and step through the code.

However, when I do this, I've noticed that any method parameters that are normally logged in the Variables section of the debug window are not showing up. Also, any regular variable declared such as

int number = 4;

won't show up either. The only variables that do show up are class member variables.

Is there something I need to add to my proguard file in order to get the rest of these variables? Thanks!

I have a nexus4 with a broken touchscreen. Controlling the bootloader with power and volume keys still works, so I put rootbox on it. Now I can login to the root prompt using adt. As I want to use it as timelapse camera, I wonder how is it possible to take a photo and save it to a specific folder using the command line? Then I could set up a cron job and download images using adt.

I am creating SearchView for my XML parsed data and I have problem passing my list from XML pull parser activity to MainActivity.

When I create custom List directly in MainActivity like as it is now in the code (Hint: List<String> items = Arrays.asList("sup1", "sup2", "sup3");), search view works fine. I tried different ways to get my list from XML parser activity, but no success...

What is the right way to pass it?

Code Below:

Main Activity:

package com.example.eronetmarket;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.FragmentTransaction;
import android.app.SearchManager;
import android.content.Context;
import android.database.MatrixCursor;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.widget.SearchView.OnQueryTextListener;
import android.util.Log;
import android.view.Menu;
import android.widget.SearchView;
import android.widget.TextView;



public class MainActivity extends FragmentActivity implements ActionBar.TabListener {


     private AppAdapter mAdapter;

     List<String> items = Arrays.asList("sup1", "sup2", "sup3");

     private Menu menu;

     @Override
     @TargetApi(Build.VERSION_CODES.HONEYCOMB)
     public boolean onCreateOptionsMenu(Menu menu) {

         getMenuInflater().inflate(R.menu.example, menu);

         this.menu = menu;

         if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {

             SearchManager manager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);

             SearchView search = (SearchView) menu.findItem(R.id.search).getActionView();

             search.setSearchableInfo(manager.getSearchableInfo(getComponentName()));

             search.setOnQueryTextListener(new OnQueryTextListener() { 

                 @Override 
                 public boolean onQueryTextChange(String query) {

                     loadData(query);

                     return true; 

                 }

                @Override
                public boolean onQueryTextSubmit(String query) {

                     loadData(query);

                     return true; 

                 }});

         }

         return true;

     }

     // History
     @TargetApi(Build.VERSION_CODES.HONEYCOMB)
     private void loadData(String query) {

         if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {

             // Load data from list to cursor
             String[] columns = new String[] { "_id", "text" };
             Object[] temp = new Object[] { 0, "default" };

             MatrixCursor cursor = new MatrixCursor(columns);

             for(int i = 0; i < items.size(); i++) {

                 temp[0] = i;
                 temp[1] = items.get(i);

                 cursor.addRow(temp);

             }

             // Alternatively load data from database
             //Cursor cursor = db.rawQuery("SELECT * FROM items", null);

             SearchManager manager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);

             final SearchView search = (SearchView) menu.findItem(R.id.search).getActionView(); 

             search.setSearchableInfo(manager.getSearchableInfo(getComponentName()));

             search.setSuggestionsAdapter(new ExampleAdapter(this, cursor, items));

         }

     }
    ViewPager viewPager=null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);          

        viewPager = (ViewPager) findViewById(R.id.pager);

        final ActionBar actionBar=getActionBar();

        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        //actionBar.setDisplayShowTitleEnabled(false);

        addTabs(actionBar);
        viewPager.setAdapter(new MyAdapter(getSupportFragmentManager()));
        viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int i, float v, int i2) {
                Log.d("VIVZ","onPageScrolled "+i+" "+v+" "+i2);
            }

            @Override
            public void onPageSelected(int i) {
                actionBar.setSelectedNavigationItem(i);
                Log.d("VIVZ","onPageSelected "+i);
            }
            @Override
            public void onPageScrollStateChanged(int i) {
                if(i==ViewPager.SCROLL_STATE_IDLE)
                Log.d("VIVZ","onPageScrollStateChanged scroll state idle "+i);
                if(i==ViewPager.SCROLL_STATE_DRAGGING)
                    Log.d("VIVZ","onPageScrollStateChanged scroll state dragging "+i);
                if(i==ViewPager.SCROLL_STATE_SETTLING)
                    Log.d("VIVZ","onPageScrollStateChanged scroll state settling "+i);
            }

        });

        }

    private void addTabs(ActionBar actionBar)
    {
        ActionBar.Tab tab1=actionBar.newTab();
        tab1.setText("PREPORUńĆENO");
        tab1.setTabListener(this);


        ActionBar.Tab tab2=actionBar.newTab();
        tab2.setText("NAJPOPULARNIJE");
        tab2.setTabListener(this);

        ActionBar.Tab tab3=actionBar.newTab();
        tab3.setText("KATEGORIJE");
        tab3.setTabListener(this);

        actionBar.addTab(tab1);
        actionBar.addTab(tab2);
        actionBar.addTab(tab3);
    }

    @Override
    public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
        viewPager.setCurrentItem(tab.getPosition());
//        Log.d("VIVZ","onTabSelected "+tab.getText());
    }

    @Override
    public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
//        Log.d("VIVZ","onTabUnselected "+tab.getText());
    }

    @Override
    public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
//        Log.d("VIVZ","onTabReselected "+tab.getText());
    }

}

class MyAdapter extends FragmentStatePagerAdapter
{

    public MyAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int i) {
        Fragment fragment=null;
        if(i==0)
        {
            fragment=new Preporuceno();
        }
        if(i==1)
        {
            fragment=new FragmentB();
        }
        if(i==2)
        {
            fragment=new FragmentC();
        }
        return fragment;
    }

    @Override
    public int getCount() {
        return 3;
    }
}

XML pull parser:

package com.example.eronetmarket;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory;

import com.example.eronetmarket.mobAppModel;

import android.content.Context;

public class XMLsourcePullParser{
    static final String KEY_APP_INFO = "appInfo";
    static final String KEY_ID = "id";
    static final String KEY_CATEGORY = "category";
    static final String KEY_ICON_URL = "iconUrl";
    static final String KEY_APP_HEADLINE = "appHeadline";
    static final String KEY_APP_DESC = "appDesc";
    static final String KEY_RATING_POINTS = "ratingPoints";
    static final String KEY_PLATFORM = "platform";
    static final String KEY_STORE_URL = "storeUrl";
    static final String KEY_STORE_PRICE = "storePrice";
    static final String KEY_DEVELOPER = "developer";

    public static List<mobAppModel> getmobAppModel(Context ctx) {

        // List of StackSites that we will return
        List<mobAppModel> appModels;
        appModels = new ArrayList<mobAppModel>();

        // temp holder for current StackSite while parsing
        mobAppModel curmobAppModel = null;
        // temp holder for current text value while parsing
        String curText = "";

        try {
            // Get our factory and PullParser
            XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
            XmlPullParser xpp = factory.newPullParser();

            // Open up InputStream and Reader of our file.
            FileInputStream fis = ctx.openFileInput("XMLsource.xml");
            BufferedReader reader = new BufferedReader(new InputStreamReader(fis));

            // point the parser to our file.
            xpp.setInput(reader);

            // get initial eventType
            int eventType = xpp.getEventType();

            // Loop through pull events until we reach END_DOCUMENT
            while (eventType != XmlPullParser.END_DOCUMENT) {
                // Get the current tag
                String tagname = xpp.getName();

                // React to different event types appropriately
                switch (eventType) {
                case XmlPullParser.START_TAG:
                    if (tagname.equalsIgnoreCase(KEY_APP_INFO)) {
                        // If we are starting a new <site> block we need
                        //a new StackSite object to represent it
                        curmobAppModel = new mobAppModel();
                    }
                    break;

                case XmlPullParser.TEXT:
                    //grab the current text so we can use it in END_TAG event
                    curText = xpp.getText();
                    break;

                case XmlPullParser.END_TAG:
                    if (tagname.equalsIgnoreCase(KEY_APP_INFO)) {
                        // if </appInfo> then we are done with current app
                        // add it to the list.
                        appModels.add(curmobAppModel);
                    } else if (tagname.equalsIgnoreCase(KEY_ID)) {

                        curmobAppModel.setid(curText);
                    } else if (tagname.equalsIgnoreCase(KEY_CATEGORY)) {

                        curmobAppModel.setcategory(curText);
                    } else if (tagname.equalsIgnoreCase(KEY_ICON_URL)) {

                        curmobAppModel.seticonUrl(curText);
                    } else if (tagname.equalsIgnoreCase(KEY_APP_HEADLINE)) {

                        curmobAppModel.setappHeadline(curText);

                    }
                    else if (tagname.equalsIgnoreCase(KEY_APP_DESC)) {

                        curmobAppModel.setappDesc(curText);

                    }
                    else if (tagname.equalsIgnoreCase(KEY_RATING_POINTS)) {

                        curmobAppModel.setratingPoints(curText);

                    }
                    else if (tagname.equalsIgnoreCase(KEY_PLATFORM)) {

                        curmobAppModel.setplatform(curText);

                    }
                    else if (tagname.equalsIgnoreCase(KEY_STORE_URL)) {

                        curmobAppModel.setstoreURL(curText);
                    }
                    else if (tagname.equalsIgnoreCase(KEY_STORE_PRICE)) {

                        curmobAppModel.setstorePrice(curText);
                    }
                    else if (tagname.equalsIgnoreCase(KEY_DEVELOPER)) {

                        curmobAppModel.setdeveloper(curText);
                    }
                    break;

                default:
                    break;
                }
                //move on to next iteration
                eventType = xpp.next();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        // return the populated list.
        return appModels;
    }
}

          Bitmap newBm = ...
          Canvas canvas = new Canvas(newBm);
          Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
          paint.setColor(Color.WHITE);
          paint.setTextSize((int) (44 * scale));
          Rect bounds = new Rect();
          paint.getTextBounds(gText, 0, gText.length(), bounds);
          canvas.drawText(gText, x, y, paint);

I drew text on the Bitmap like so. How could I get a grey background that is the same height as the text but covers the whole screen??

I'm looking for a way to display my list of images from a mysql database, in my android application. The images are blob type, and I have already managed to display a list of strings.

Java

 public class AfficherTousMagasinActivity extends ListActivity {
    ImageView  img2;     Bitmap bitmapOrg;
    // Progress Dialog  
    private ProgressDialog pDialog;
    // Creating JSON Parser object
    JSONParser jParser = new JSONParser();
    ArrayList<HashMap<String, Object>> productsList;
    // url to get all products list
    private static String url_all_products="http://10.0.2.2/android700/get_all_products.php";
    // JSON Node names
    private static final String TAG_SUCCESS = "success";
    private static final String TAG_PRODUCTS = "produitpromo";
    private static final String TAG_ID_Produit = "ID_Produit";
    private static final String TAG_NomProduit = "NomProduit";
    private static final String TAG_description ="description";
    private static final String TAG_Prix_initial ="Prix initial";
        private static final String TAG_Prix_promotion ="prix_promotion";
    private static final String TAG_Prix_Photo ="Photo";
    // products JSONArray
    JSONArray promo = null;//NomProduit Prix initial prix_promotion description  ID_Produit
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);         
    img2 = (ImageView) findViewById(R.id.Photo);            
    setContentView(R.layout.aficher_magasin);
    final Intent callingIntent = getIntent();
    String sessionemail = callingIntent.getStringExtra("sessionemail");             
    // Hashmap for ListView
    productsList = new ArrayList<HashMap<String, Object>>();
    // Loading products in Background Thread
    new LoadAllProducts().execute();
    // Get listview
    ListView lv = getListView();
    // on seleting single product
    // launching Edit Product Screen
    lv.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
    // getting values from selected ListItem
    String ID_Produit = ((TextView) view.findViewById(R.id.ID_Produit)).getText().toString();
    String NomProduit = ((TextView) view.findViewById(R.id.NomProduit)).getText().toString();
    String Prixinitial = ((TextView) view.findViewById(R.id.Prix_initial)).getText().toString();
    String prixpromotion = ((TextView) view.findViewById(R.id.Prix_promotion)).getText().toString();
    String description = ((TextView) view.findViewById(R.id.description)).getText().toString();             
    // Starting new intent
    Intent in = new Intent(AfficherTousMagasinActivity.this,    panier.class);
    // sending ID_Produit to next activity
    in.putExtra("ID_Produit", ID_Produit);
    in.putExtra("NomProduit", NomProduit);
    in.putExtra("Prixinitial", Prixinitial);
    in.putExtra("prixpromotion", prixpromotion);
    in.putExtra("description", description);                            
    // starting new activity and expecting some response back
    startActivityForResult(in, 100);}   }); }
    // Response from Edit Product Activity
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // if result code 100
    if (resultCode == 100) {
    // if result code 100 is received 
    // means user edited/deleted product
    // reload this screen again
    Intent intent = getIntent();
    finish();
    startActivity(intent);
    }   }
    class LoadAllProducts extends AsyncTask<String, String, String> {
    @Override
    protected void onPreExecute() {
    super.onPreExecute();
    pDialog = new ProgressDialog(AfficherTousMagasinActivity.this);
    pDialog.setMessage("Loading promo. attendez s'il vous plait...");
    pDialog.setIndeterminate(false);
    pDialog.setCancelable(false);
    pDialog.show();
    }    
    protected String doInBackground(String... args) {
    String str1="";         
    // Building Parameters
    List<NameValuePair> params = new ArrayList<NameValuePair>(); 
    // getting JSON string from URL
    JSONObject json = jParser.makeHttpRequest(url_all_products, "GET", params);         
    // Check your log cat for JSON reponse
    Log.d("All Products: ", json.toString());
    try {// Checking for SUCCESS TAG
    int success = json.getInt(TAG_SUCCESS);             
    if (success == 1) {                         
    promo = json.getJSONArray(TAG_PRODUCTS);
    // looping through All Products
    for (int i = 0; i < promo.length(); i++) {
    JSONObject c = promo.getJSONObject(i);
    // Storing each json item in variable
    String ID_Produit = c.getString(TAG_ID_Produit);
    String Prix = c.getString(TAG_NomProduit);
    String description = c.getString(TAG_description);
    String Prix_initial = c.getString(TAG_Prix_initial);
    String Prix_promotion = c.getString(TAG_Prix_promotion);
    str1 = c.getString(TAG_Prix_Photo);
    byte[] ba2 = Base64.decode(str1);           
    Bitmap bitmap = BitmapFactory.decodeByteArray(ba2 , 0, ba2 .length);        
    Drawable d = new BitmapDrawable(getResources(),bitmap);                                       
    // creating new HashMap
    HashMap<String, Object> map = new HashMap<String, Object>();
    // adding each child node to HashMap key => value
    map.put(TAG_ID_Produit, ID_Produit);
    map.put(TAG_NomProduit, Prix);
    map.put(TAG_description, description);
    map.put(TAG_Prix_initial, Prix_initial);
    map.put(TAG_Prix_promotion, Prix_promotion); 
    map.put(TAG_Prix_Photo,d);                                           
    productsList.add(map);  }                           
    } else {        }
    } catch (JSONException e) { e.printStackTrace();} 
    return null;}       
    protected void onPostExecute(String file_url) {
    // dismiss the dialog after getting all products
    pDialog.dismiss();
    // updating UI from Background Thread
    runOnUiThread(new Runnable() {
    public void run() {
    /**
 * Updating parsed JSON data into ListView
 * */
    ListAdapter adapter = new SimpleAdapter(
    AfficherTousMagasinActivity.this, productsList, R.layout.list_item, new String[] { TAG_ID_Produit,TAG_NomProduit,TAG_description,TAG_Prix_initial,TAG_Prix_promotion,TAG_Prix_Photo},
    new int[] { R.id.ID_Produit, R.id.NomProduit,R.id.description, R.id.Prix_initial, R.id.Prix_promotion,R.id.Photo});
    // updating listview
    setListAdapter(adapter);    
    }
    });     }

PHP

<? php
// array for JSON response
$response = array();
// include db connect class
require_once __DIR__.
'/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
// get all products from products table
$result = mysql_query("SELECT *FROM produitpromo") or die(mysql_error());
// check for empty result
if (mysql_num_rows($result) > 0) {
    $response["produitpromo"] = array();
    while ($row = mysql_fetch_array($result)) {
        // temp user array
        $product = array();
        $product["ID_Produit"] = $row["ID_Produit"];
        $product["NomProduit"] = $row["NomProduit"];
        $product["Prix initial"] = $row["Prix initial"];
        $product["prix_promotion"] = $row["prix_promotion"];
        $product["description"] = $row["description"];
        $product["Photo"] = base64_encode($row["Photo"]);
        // push single product into final response array
        array_push($response["produitpromo"], $product);
    }
    // success
    $response["success"] = 1;
    // echoing JSON response
    echo json_encode($response);
} else {
    // no products found
    $response["success"] = 0;
    $response["message"] = "No products found";
    // echo no users JSON
    echo json_encode($response);
} ?>

I understand that it's a bad deal to stock images in a database, so I'm open to any suggestions.

Quick note, I am new to programming Android applications so feel free to say I'm going about this the entirely wrong way or even to explain things to me like I'm an idiot.

My application is very location dependent. I am using the Google Play Location Services to provide the users current location. Users can store locations in their device which I store using a hashmap. In order to make it more convenient I am trying to make it so the user only has to be within a range of that stored location. My current method to create this range is to essentially use a for loop to scan the user's current location to see if it is in the hashmap.

 public String scan(Location local) {
    String fLoc = "";
    List<String> pLoc = new ArrayList<String>();
    String loc = "";
    double lat = local.getLatitude();
    double lon = local.getLongitude();
    lat = (double) Math.round(lat * decimal) / decimal;
    lon = (double) Math.round(lon * decimal) / decimal;
    for (double x = -8; x < 9; x++) {
        double tlat = lat;
        double tlon = lon;
        tlat = tlat + (x / decimal);
        tlat = (double) Math.round(tlat * decimal) / decimal;
        for (double y = -8; y < 9; y++) {
            tlon = lon;
            tlon = tlon + (y / decimal);
            tlon = (double) Math.round(tlon * decimal) / decimal;
            loc = ("Latitude: " + tlat + "   Longitude: " + tlon);
            if (locMap.containsKey(loc)) {
                pLoc.add(loc);
            }

        }
    }
    if (pLoc.isEmpty()) {
        lat = local.getLatitude();
        lon = local.getLongitude();
        lat = (double) Math.round(lat * decimal) / decimal;
        lon = (double) Math.round(lon * decimal) / decimal;
        loc = ("Latitude: " + lat + "   Longitude: " + lon);
        fLoc = loc;
    } else if (pLoc.size() == 1) {
        fLoc = (String) pLoc.toArray()[0];
    } else {
        Double diff = 0.0;
        Double tdiff = 10.0;
        for (String l : pLoc) {
            diff = 10.0;
            String[] parts = l.split(" ");
            double dlat = Double.parseDouble(parts[1]) - lat;
            if (dlat < 0) {
                dlat = dlat * -1;
            }
            double dlon = Double.parseDouble(parts[5]) - lon;
            if (dlon < 0) {
                dlon = dlon * -1;
            }
            diff = dlon + dlat;

            if (diff < tdiff) {
                tdiff = diff;
                fLoc = l;
            }
        }

    }
    return fLoc;
}

If no location is close, the user's current location is returned. I feel this is a crude method that is wasteful. What is a better way to find nearby locations? Maybe a for loop through saved location to see if the difference between it and the nearby location is small enough, but this could get costly when the user starts save lots of locations.

Any suggestions?

PS Any tips on adding accurate elevation without barometers?

I am developing an app for android with QT/QML. To switch between screens I use this pageloader:

Rectangle {
id: mainApp
visible: true
width: 768
height: 1030


    signal handlerLoader(string name, int index)
    Loader {
        id:pageLoader
        source:"mainMenu.qml"
    }
    Connections {
        target:pageLoader.item
        onHandlerLoader:{pageLoader.source=name;
            if(index===2)
                window.source="NewWindow.qml";
        }
    }}

In a menu I have a button somewhere where another screen is loaded:

Button {
          id: continueButton
          width: 600
          height: 150

          text: "Continue with last template"
          onClicked: handlerLoader("Template_water.qml",0)
      }

This works, because Template_water.qml is in the qml.qrc file. But now I want to load in another file which is on the external storage on my android device: "/storage/emulated/0/Download/Template_water.qml". But it is not described in the qml.qrc file so it doesn't load. How can I solve this? (I want it to be able to add a qml file after deployment on the device.)

I have a custom class called DatePicker who extends DialogFragment and implements DatePickerDialog.OnDateSetListener, but my problem is because y need to listen the onDateChangeMethod and the DialogFragment only have DialogInterface.OnCancelListener and DialogInterface.OnDismissListener.

How can I do that? I tried to implement OnDateChangedListener and override the onDateChange method but it did not work. Here is the code:

public class DatePicker extends DialogFragment implements
        DatePickerDialog.OnDateSetListener, OnDateChangedListener {

    private OnDateSetListener _onDateSetListener;

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);

        _onDateSetListener = (OnDateSetListener) activity;
    }


    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Date initialValue = null;
        String[] buttons = getArguments().getStringArray("buttons");

        Long initialValueLong = getArguments().getLong("initialValue");
        if (initialValue == null) {
            initialValue = new Date();
        }

        Calendar calendar = GregorianCalendar.getInstance();
        calendar.setTimeInMillis(initialValueLong);

        DatePickerDialog dialog = new DatePickerDialog(getActivity(), this,
                calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DATE));


        return dialog;
    }

     @Override
     public void onDateSet(android.widget.DatePicker view, int year,
           int monthOfYear, int dayOfMonth) {
           _onDateSetListener.onDateSet(new GregorianCalendar(year, monthOfYear,
               dayOfMonth).getTime(), getArguments().get("tag"));
     }

    @Override
    public void onDateChanged(android.widget.DatePicker view, int year,
            int monthOfYear, int dayOfMonth) {

        // THIS METHOD NEVER CALLED

    }
}

I have a multi library android project, there is a problem: Most of times I should run app more than one time to have changes to my libraries applied in main project. Seems compiler doesn't sense changes to my codes in first compile. And after second or third run it prompts this in console:

Dx 
trouble writing output: already prepared

Then it applies all changes!

It can be fixed by Clean & Rebuild, but happens again.

I have a drawable that I would like to use as a background for a textView. The drawable is declared in the xml as a textView background. I am having a problem when testing the drawable on different screen sizes, as sometimes it stretches out and turns into an oval shape instead of staying as a circle.

So, specifically, my question is as follows: Is there any way to make sure that a drawable is always a circle and does not stretch into an oval? Preferably I would like everything to be done in XML.

I can post some of my code, but I think it is unnecessary because it is a simple drawable that uses the oval shape, and then in the layout I set the drawable to the background of a textView. My attempt to make the drawable to a circle was to use weights and a linear layout, and for the most part it works but it still stretches a bit in some screen sizes.

For completeness, if anyone is interested here is the layout code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="6"
    android:text="Button" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="4"
    android:gravity="center_horizontal|bottom"
    android:text="Text"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<ImageView
    android:id="@+id/gradientline1"
    android:layout_width="match_parent"
    android:layout_height="2dp"
    android:src="@drawable/gradient_line" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="8"
    android:gravity="center"
    android:text="Text"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="4"
    android:gravity="center_horizontal|bottom"
    android:text="Text"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<ImageView
    android:id="@+id/gradientline2"
    android:layout_width="match_parent"
    android:layout_height="2dp"
    android:src="@drawable/gradient_line" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="24"
    android:orientation="horizontal" >

    <View
        android:layout_width="1dp"
        android:layout_height="0dp"
        android:layout_weight="5" >
    </View>

    <TextView
        android:id="@+id/textView4"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="20"
        android:background="@drawable/circle"
        android:gravity="center"
        android:text="Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <View
        android:layout_width="1dp"
        android:layout_height="0dp"
        android:layout_weight="5" >
    </View>
</LinearLayout>

and here is the circle drawable (just layers of circles):

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

<item>
    <shape android:shape="oval" >
        <solid android:color="@color/circle_one" />
    </shape>
</item>
<item
    android:bottom="3dp"
    android:left="3dp"
    android:right="3dp"
    android:top="3dp">
    <shape android:shape="oval" >
        <solid android:color="@color/circle_two" />
    </shape>
</item>
<item
    android:bottom="10dp"
    android:left="10dp"
    android:right="10dp"
    android:top="10dp">
    <shape android:shape="oval" >
        <solid android:color="@color/circle_three" />
    </shape>
</item>
<item
    android:bottom="12dp"
    android:left="12dp"
    android:right="12dp"
    android:top="12dp">
    <shape android:shape="oval" >
        <solid android:color="@color/circle_two" />
    </shape>
</item>
<item
    android:bottom="16dp"
    android:left="16dp"
    android:right="16dp"
    android:top="16dp">
    <shape android:shape="oval" >
        <solid android:color="@color/circle_three" />
    </shape>
</item>
<item
    android:bottom="28dp"
    android:left="28dp"
    android:right="28dp"
    android:top="28dp">
    <shape android:shape="oval" >
        <solid android:color="@color/circle_one" />
    </shape>
</item>

I have a splash screen with my company's logo in the center of it with a little progress bar under it. I launch the splash as the first activity, and before that happens I display an image of the splash (without the progress bar, just the logo) using the app's theme background.

I placed a 9 patch image of the in the app's theme android:windowBackground, and when the extension of that file is .9.png - the splash activity is displayed on the top left corner of the screen in a smaller size. Changing the extension to .png makes the splash display correctly over the whole screen, but of course my first image is stretch horribly ,because it's much smaller than the screen.

Anybody experienced this issue? Couldn't find it online. Thanks for the help.

Hi I am trying to implement serach on my application without using actual search function. The serach activity will initiate after the option search is clicked. But after clicking this i m getting a blank screen.

Here is my SearchActivity file

public class SearchResultsActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
 // TODO Auto-generated method stub
 super.onCreate(savedInstanceState);
 //setContentView(R.layout.searchable); 

 // Get the intent, verify the action and get the query
   Intent intent = getIntent();
   if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
    String query = intent.getStringExtra(SearchManager.QUERY);
    Toast.makeText(SearchResultsActivity.this, 
     query, 
     Toast.LENGTH_LONG).show();
  }
  }

  }

Please help me in this code. Let me know if you need some more information.
Thanks in advance :)

I'm an dev still learning in Android, I've created two apps so far, an alarm clock, a widget and a pass manager using databases, I have a little bit of experience, but I'd like to create a 2D side scroller game, I check on the web and there are different tutorials, but, what's the best way to start working on it? I've read about libgdx but I'm not sure if it's outdated.

I've seen that all the games are made in Java, and then ported to Android, is this correct? I would appreciate some guidance, thanks!

Is this not even slightly possible:

First one sets TextColor to Black as default throughout the App

<style name="MyTheme" parent="android:Theme.Light.NoTitleBar.Fullscreen">
    <item name="android:imageButtonStyle">@style/Style.ImageButton</item>
    <item name="android:textViewStyle">@style/Style.TextView</item>
</style>

Second one sets the TextColor wherever there is a toolbar

<style name="MyTheme.Toolbar">
    <item name="android:textViewStyle">@style/Style.TextView.Light</item>
    <item name="android:imageButtonStyle">@style/Style.ImageButton</item>
</style>

And the Text styles:

<style name="Style.TextView" parent="@android:style/Widget.TextView">
    <item name="android:textColor">@color/color_black</item>
</style>

<style name="Style.TextView.Light" parent="@android:style/Widget.TextView">
    <item name="android:textColor">@color/color_white</item>
</style>

Then in my Layout:

<LinearLayout
    android:id="@+id/main_toolbar"
    style="@style/MyTheme.Toolbar"
    android:weightSum="9" >

    <TextView
        android:id="@+id/main_toolbar_title"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="4"
        android:gravity="center_vertical|left"
        android:text="@string/app_name" />

</LinearLayout>

At this point, the text here on this TextView should preferably be White but it's Black, since I've set the background (not included though) to a dark background on the toolbar.

It's the same wether I set the parent of the styles to the text to "@android:style/Widget.TextView" or "@android:attr/textViewStyle" as well, no change.

What is the point of having styling and themes and such if this layout does not work? Change the color of each Toolbar with one click, instead of changing hundreds (if there are hundreds) manually seems like a drag. Android needs to rethink this system if it isn't the case.

Also, is there a good reference list for all the styles to "inherit" since Eclipse does not seem to have any support to this. It's just guestwork and checking the "platforms/src/res/values.xml" files for potential candidates to extend from. Like, I can understand that maybe "MyTheme.Toolbar" needs to inherit from LinearLayout, or maybe it doesn't work this way at all. But would be preferable. Since XML is hierarchy system and everything is set up like this, seems stupid alltogether if it's not possible. It would save lots of time and the code would be less, easier to manage.

I'm working with an horizontal scroll view composed of a maximum number of 10 Network Image View, added programmatically to the horizontal scroll view.

The problem I'm trying to figure out is simple. My objective is to show one image at a time when the user scrolls the view. Basically, I'd like to realize a slideshow similar to the app "AutoScout24". I tried to add a Scroll Listener, but it doesn't behave as I wanted.

Thank you for your help. If you need it, I may post the code of the listener.

I would like to have the ability when selecting a group, that after it expands it automatically selects the first child. My code is as follows:

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    ExpandableListView listView = (ExpandableListView) getActivity().findViewById(R.id.list);

    listView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
        @Override
        public void onGroupExpand(int groupPosition) {
            listView.setSelectedChild(groupPosition, 0, true);
        }
    });

    getLoaderManager().restartLoader(0, null, this);
}

My adapter for my list is a CursorTreeAdapter. I'm assuming that setSelectedChild(...) is not working because when myCursorTreeAdapter.getChildrenCursor(...) gets called, it loads the cursor of children in the background, and setSelectedChild(...) is getting called PRIOR to the myCursorTreeAdapter.getChildrenCursor(...) finishing (so there are no children YET when the call is being made).

I have tried to look for some sort Listener on the CursorTreeAdapter (to know when the children finish getting loaded)... but there does not seem to be any ability to add a Listener there.

Does anyone have any ideas on solve this issue?

I'm using the default android NumberPicker and am having issues when using the setValue() method.

Just to note, the issues are occurring when i run API Level 16(Galaxy SII), I have tried an API Level 14 emulator and there are no issues so i'm a bit baffled.

My fragment contains number pickers and the numbers are saved to a DB table. I am returning the values to the number pickers when the fragment is accessed again.

Initially this works but if i replace the fragment in the activity, and then call the fragment again, the number pickers will display "0" but if i increase or decrease it, it will update from the number that it should be displaying. So 0 would jump to 5 if the number that is saved to the DB is 4.

Has anybody come across this and could they direct me on how to resolve this issue?

Thanks.

My app is not yet published and since it is large I would like to use android:installLocation="preferExternal" in the manifest to allow the OS to install on external storage. I also have an assets folder as part of the APK and I am using the AssetManager to access them from code. Given these, do I need to add to the manifest android.permission.READ_EXTERNAL_STORAGE as well?

My Location Listener doesn't work until I enable Wifi connection. If turn on only GPS it doesn't happen anything, also the 'blue point' doesn't appear. Yesterday was working fine and today I didn't changed this code, this morning I was trying to use mock location to test it on my device and I installed Fake GPS (and disinstalled), maybe it's it the problem?

package com.example.mapstest;


import com.google.android.gms.maps.*;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.PolylineOptions;

import android.location.*;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.*;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Color;

public class MainActivity extends ActionBarActivity  {

    static GoogleMap map;
    static LocationManager lManager;
    static boolean alreadyStarted=false;
    static Listener listener;
    static String provider;
    static String _mapName;
    static Context context;
    static LatLng previous = null;
    static Button start, stop, newRun;
    String desc;


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

        context = getApplicationContext();
        Intent in= getIntent();
        Bundle b = in.getExtras();
        if(b!=null) {
            String name = (String) b.get("name");
            _mapName = name;
            this.setTitle("Map: " + _mapName);
            desc = (String) b.get("desc");
        } 


        DBAdapter dbAdapter = new DBAdapter(context);
        dbAdapter.open();
        Cursor res = dbAdapter.getMap(_mapName);
        res.moveToFirst();
        int x = res.getInt(res.getColumnIndex("created"));
        dbAdapter.close();
        if(x == 1) {
            alreadyStarted = true;
        }

        map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
        lManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
        dbAdapter = new DBAdapter(getApplicationContext());
        dbAdapter = new DBAdapter(context);
        dbAdapter.open();
        Cursor pointCursor = dbAdapter.getPoint(_mapName);
        previous = null;
        boolean first=true;
        LatLng firstPoint=null;
        if (pointCursor.moveToFirst()){     
            do{
                double lat = Double.parseDouble(pointCursor.getString(pointCursor.getColumnIndex("lat")));
                double lon = Double.parseDouble(pointCursor.getString(pointCursor.getColumnIndex("lon")));
                if(first) {
                    firstPoint = new LatLng(lat,lon);
                }
                addTrack(lat, lon);
                CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(firstPoint, 20);
                map.animateCamera(cameraUpdate);
            } while(pointCursor.moveToNext());
        } 
        previous = null;
        dbAdapter.close();
    } 

    static void addTrack(double lat, double lon){
        if(previous !=null) {   
            map.addPolyline(new PolylineOptions()
            .add( previous,
                    new LatLng(lat, lon)
                    )
                    .width(9)
                    .color(Color.rgb(30,144,255)));
            previous = new LatLng(lat, lon);
        }
        else previous = new LatLng(lat, lon);
        CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLng(new LatLng(lat, lon));
        map.animateCamera(cameraUpdate);
    }

    static String getProvider() {
        return provider;
    }

    static String getMapName() {
        return _mapName;
    }

    static void stopService() {
        Toast.makeText(context, "Stopping services", Toast.LENGTH_SHORT).show();
        lManager.removeUpdates(listener);
        lManager.removeGpsStatusListener(listener);
        map.setMyLocationEnabled(false);
    }

    public void onDestroy(){
        super.onDestroy();
        Toast.makeText(getApplicationContext(), "On Destroy" , Toast.LENGTH_SHORT).show();
        if(listener!=null)
            stopService();
        alreadyStarted=false;   
        Toast.makeText(context, "6", Toast.LENGTH_SHORT).show();
        finish();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch(item.getItemId()){
        case R.id.action_start:
            if(lManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){
                if(!alreadyStarted){
                    Criteria criteria = new Criteria();
                    provider = lManager.getBestProvider(criteria, false);
                    map.setMyLocationEnabled(true);
                    listener = new Listener(this);
                    lManager.addGpsStatusListener(listener);
                    alreadyStarted = true;
                }
            }
            else {
                startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
                Toast.makeText(getApplicationContext(), "Enable GPS and press again start", Toast.LENGTH_SHORT).show();
                alreadyStarted = false;

            }
            return true;
        case R.id.action_stop:
            if(alreadyStarted)
                stopService();
            Toast.makeText(context, "5", Toast.LENGTH_SHORT).show();
            return true;
        case R.id.action_newRun: 
            DBAdapter dbAdapter = new DBAdapter(getApplicationContext());
            dbAdapter.open();
            Cursor res = dbAdapter.getPoint(_mapName);
            if(res.getCount()>0) {          
                AlertDialog.Builder alert = new AlertDialog.Builder(this);
                alert.setTitle("New...");
                LinearLayout layout = new LinearLayout(context);
                layout.setOrientation(LinearLayout.VERTICAL);
                final TextView namemap = new TextView(this);
                namemap.setText("Map:");
                final EditText mapName = new EditText(this);
                final TextView descmap = new TextView(this);
                descmap.setText("Description:");
                final EditText mapDesc = new EditText(this);
                layout.addView(namemap);
                layout.addView(mapName);
                layout.addView(descmap);
                layout.addView(mapDesc);
                alert.setView(layout);

                alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        DBAdapter dbAdapter = new DBAdapter(getApplicationContext());
                        dbAdapter.open();
                        if(dbAdapter.containsMap(mapName.getText().toString())) Toast.makeText(getApplicationContext(), "Map already exists", Toast.LENGTH_SHORT).show();
                        else {
                            dbAdapter.insertMap(mapName.getText().toString(), mapDesc.getText().toString());
                            StartActivity.list.add(mapName.getText().toString());
                            StartActivity.adapter.notifyDataSetChanged();
                            Intent newRunActivity = new Intent(getApplicationContext(),NewRun.class);
                            newRunActivity.putExtra("name", mapName.getText().toString());
                            newRunActivity.putExtra("originalname", _mapName);
                            startActivity(newRunActivity);
                        }
                        dbAdapter.close();
                    }
                });

                alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        // Canceled.
                    }
                });

                alert.show();
            }
            else Toast.makeText(context, "Empty map", Toast.LENGTH_SHORT).show();
            return true;
        }
        return false;

    }
}

And this is the manifest

  <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mapstest"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

    <!--
     The following two permissions are not required to 4use
     Google Maps Android API v2, but are recommended.

    -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/icorun"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.mapstest.MainActivity"
            android:label="@string/app_name" >
        </activity>

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyDkv5eSkdaFa2OVFlYsKnHFXS5C3Yjem9Q" />

        <activity
            android:name="com.example.mapstest.StartActivity"
            android:label="@string/title_activity_start" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.example.mapstest.CreateActivity"
            android:label="@string/title_activity_create" >
        </activity>
        <activity
            android:name="com.example.mapstest.NewRun"
            android:label="@string/title_activity_new_run" >
        </activity>
    </application>

</manifest>

I do RequestLocationUpdates in another class (Listener) with MainActivity.lManager.requestLocationUpdates(provider, 1500, 0, this);

I am trying to change the color of the little triangle on the Actionbar spinner (sherlock). I have done so using the following code:

<style name="MyTheme" parent="Theme.Sherlock.Light">
    <item name="windowActionBarOverlay">true</item>
    <item name="homeAsUpIndicator">@drawable/ic_drawer</item>
    <item name="actionDropDownStyle">@style/MyActionBarSpinnerStyle</item>

</style>

<style name="MyActionBarSpinnerStyle" parent="@style/Widget.Sherlock.Light.Spinner.DropDown.ActionBar">
    <item name="background">@drawable/actionbar_spinner_background</item>
</style>

The icon triangle is changed but it seems to stretch the image to the whole size of the spinner.

image

I am using the patch-9 drawable file that everyone says to use: spinner

If this is not the correct dimensions of the file then does anyone know what it should be? Or how do I get it not to stretch and just sit in the bottom right hand corner.

Thank you.

what I'm trying to do was fetch the current Facebook user profile and make them into JSON objects, and then send a request to a server. However, the only value which I can see from the LogCat was the user id value. Other than the user id, everything was showed up to null. I tried every single values such as user name, email, gender etc.. Unfortunately, I couldn't get any other data. Can anybody could tell me what is wrong with my codes, and how to fix them?

Also I was checking with the terminal whether the request is working or not.

sudo tcpdump -vvvs 1024 -n dst host myipaddress

My code

    private class Connection extends AsyncTask<GraphUser,Integer,String>{


    @Override
    protected String doInBackground(GraphUser... user) {
        // TODO Auto-generated method stub
        postData(user[0]);
        return null;
    }

    protected void onPostExecute(String result){
        super.onPostExecute(result);
        Log.d(TAG3,"DATA SENT");
    }


        public void postData(GraphUser user){
        HttpClient httpclient = new DefaultHttpClient();
        HttpConnectionParams.setConnectionTimeout(httpclient.getParams(), 10000); //Timeout Limit
        HttpPost httppost = new HttpPost("http://domain/www/jeffcodes/FbUser.php");
        //httppost.setHeader("Content-type","application/json");
        httppost.setHeader("Accept", "application/json");
        Log.d(TAG3,"OK1");

        try {


            // Build the JSON object to pass parameters
            JSONObject jsonObj = new JSONObject();
            jsonObj.put("id", user.getId());
            jsonObj.put("name", user.getName());
            jsonObj.put("gender", user.getProperty("gender"));
            jsonObj.put("location", user.getProperty("name"));
            jsonObj.put("locale", user.getProperty("locale"));
            jsonObj.put("birthday", user.getBirthday());
            jsonObj.put("email", user.getProperty("email"));


            StringEntity se = new StringEntity( jsonObj.toString());  
            se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
            httppost.setEntity(se);
            Log.d(TAG3,"OK2");

            // Execute HTTP Post Request
            HttpResponse response = httpclient.execute(httppost);

            String responseString = EntityUtils.toString(response.getEntity(), HTTP.UTF_8);
            //Except for id value, everything was null

            Log.d(TAG4, responseString);
            Log.d(TAG3,"OK3");

        }catch (JSONException e) {
            e.printStackTrace();
        }catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }



        }