I wants to ask that suppose i wants to make a view like as given below image

Now i wants to know is it efficient to have a custom list-view for this or a simple linear layout with elements which can be inflated and added to another layout, as i do not wants to have any click operation over the items , i just need to show them over a screen. which one will be better approach?

I already know how to make Custom ListViews

enter image description here

In my android app I need to check whether a particular view is focussed. Now I found the getCurrentFocus() function in Activity class but this returns a View Object.

How can I compare and check whether this returned View is same as the one in question. I mean there is no getName() function here. So after getting the View object, how can I compare to check which View class is this ?

I've got a problem with fragmentactivity and onCreate method. My classes looks like this:

public abstract class B extends FragmentActivity implements View.OnKeyListener

public class A extends B

    protected void onCreate(Bundle savedInstanceState) 
        // stuff

OnCreate in class A is not called. I created layout from another after click and onCreate is in second layout. I don't know where is the problem.

So I have created a button in my layout, but I wanted it to be a circle. So I created an .xml drawable like this -

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    <solid android:color="#673ab7"/>
    <stroke android:width="2sp" android:color="#fff" />

Then in the button bit in the layout i added this - android:background="@drawable/circle_button" But now I wish to have an image inside the circler button. How can I achieve this? Can I simply add something in the drawable xml?

I've tried searching for answers but I am confused to what I should search for.

My App is ready for Alpha and later, Beta testing. Up until now for testing my Google Play Leaderboards, I used the standard debug.keystore.

Now, I'm ready to upload my APK for the first time to the Play Store for my test groups. I've therefore signed the APK with my own private key.

So when I install the app from my exported APK, I now cannot connect to Google Play Service to access the leaderboards (expected behavior).

I looked around on SO and I saw a question which suggested that I needed to sign my test APK with my own key and this must be the same key that the final production APK will use.

  • Question - Is this correct? Does my Alpha / Beta and Production APK's have to be signed using the same keystore?

Someone also mentioned that you can add private keystore details to your project in the Developers Console

  • Is this correct? I've looked but I can't see where to do this?!

And, on this page, it states the following:

Important: When you prepare to release your app to your users, you must follow these steps again and create a new OAuth 2.0 client ID for your production app. For production apps, you will use your own private key to sign the production app's .apk file. See Signing your applications for more information.

This seems to suggest that the first point above isn't correct? i.e. I can use a debug keystore when I upload APK's for Alpha / Beta testing, but for 'production apps' - which I read as 'final ready to go / post testing' - apps need to have a private key, therefore, not the same as test APK's.

  • Is the above correct and true for my leaderboard situation?

I find it a bit confusing, so I may have misunderstood some of the things I've read, but would be grateful if someone could clear up my confusion!

I have a custom class which extends AlertDialog. I would like to create a dialog with which I can control the width, height, x, and y positions programmatically. Here is what I currently have:

MyDialog md = new MyDialog(context, AlertDialog.THEME_HOLO_LIGHT);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.x = 100;
lp.y = 400;
lp.width = 200;
lp.height = 400;

If I remove the setMessage line, no dialog is displayed. If I leave it in though it will show a blank dialog that acts strangely:

  1. The height of the dialog seems locked in to the height of a single line of text rather than using the height value that is set.

  2. The dialog APPEARS to be one line tall, however, it does not allow it to go any lower on the screen than the set height would allow. A dialog positions itself on screen to ensure that all of it is always visible, which is why this occurs.

Also, if I add a lot of text to the setMessage method the dialog will stretch to contain all of it, is there a way to set it so that it crops whatever does not fit?

In summary: It appears that alert dialog does quite a bit behind the scenes in terms of formatting that I would like to disable. Is there a better way to format a dialog? The solution to this problem MUST use Dialog as a base class. Thanks in advance.

I'm a newie using Retrofit, and I was seraching for a automatic way to generate the class types for consume a rest web service with retrifit becouse as far as I've seen I'm suposed map all the objects that returns the server.

Specifically I want to work with a Endpoint Django REST framework 2.3.14 with a lot of elements by each method, Thats why I want to generate in an automatic way the element types.

I've seen some with JAX-RS but I'm not sure it works with django Rest Services.

Any help would be very appreciated. Thanks

In my App I have:

  • DataManager class - a singleton which holds data
  • Activity which shows a 'loading' fragment until the data is ready, and then once it is ready, it replaces it with a 'content' fragment. (I do this with the replace() method, since I no longer have use for the 'loading' fragment)

The following flow causes (sometimes) a null pointer exception:

  • Open app and wait for the data to be loaded (meaning, until we get to the 'content' fragment)
  • leave the app using the home button
  • open the app after a while (after Android kills the app)

What happens is that the app resumes to the 'content' fragment, but the data from the DataManager is null. This happens because Android kills my app, but when I resume, it saves the state, meaning it shows the 'content' fragment automatically.

Is there a way for me to tell the app not to create the 'content' fragment in this scenario? The solution I currently have in mind is to create a 'loading' Activity instead of a fragment, but i'd like to avoid that.

I've been scratching my head for a few days and I hope someone can help me out. I'm trying to implement leaderboards in my game and I can't figure out what I'm doing wrong! When my game starts up, I see the "Connecting to Google Play Games" screen load up and then I'm able click the "sign in" button.

After that I get a message saying "Unknown issue with Google Play Service". I went through the documentation and a few tutorials but still can't figure out what is wrong.

Here is my code:

public class AndroidLauncher extends AndroidApplication implements GameInterface, GameHelper.GameHelperListener {

    protected RelativeLayout layout;
    protected GameHelper gameHelper;

    public void onCreate (Bundle savedInstanceState) {
        gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
        gameHelper.enableDebugLog(true, "GameHelper");

        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();

         // Create the layout
        layout = new RelativeLayout(this);

        // Do the stuff that initialize() would do for you

        // Create the libgdx View
        View gameView = initializeForView(new BirdBlast(this), config);



        // Hook it all up

        if(!gameHelper.isSignedIn()) {


    public void onActivityResult(int request, int response, Intent data) {
        super.onActivityResult(request, response, data);
        gameHelper.onActivityResult(request, response, data);

    public void onSignInFailed() {
        System.out.println("TEST: " + gameHelper.isSignedIn());

    public void onSignInSucceeded() {
        System.out.println("TEST: " + gameHelper.isSignedIn());

Here is my logcat output:

07-14 19:19:43.920  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: onActivityResult: req=RC_RESOLVE, resp=RESULT_OK
07-14 19:19:43.920  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: onAR: Resolution was RESULT_OK, so connecting current client again.
07-14 19:19:43.920  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: Starting connection.
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: onConnectionFailed
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: Connection failure:
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper:    - code: INTERNAL_ERROR(8)
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper:    - resolvable: false
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper:    - details: ConnectionResult{statusCode=INTERNAL_ERROR, resolution=null}
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: onConnectionFailed: WILL resolve because user initiated sign-in.
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: onConnectionFailed: resolving problem...
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: resolveConnectionResult: trying to resolve result: ConnectionResult{statusCode=INTERNAL_ERROR, resolution=null}
07-14 19:19:44.871  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: resolveConnectionResult: result has no resolution. Giving up.
07-14 19:19:44.871  25791-25791/com.mypackage.mygame W/GameHelper﹕ disconnect() called when client was already disconnected.
07-14 19:19:44.911  25791-25791/com.mypackage.mygame D/GameHelper﹕ GameHelper: Notifying LISTENER of sign-in FAILURE (error)

I am working on a simple mobile app that controls the camera from phone. I am interested to take pictures with custom shutter speed. UP to 30 second exposures are easily controlled by setting the shutter speed via API, however longer exposures require use of BULB mode.

Is there way take a picture with BULB mode from the Camera Remote API?

This seems to be a blocker for some use cases i.e. extended bracketing and some weird forms of time-lapse that I want to shoot.

PS I am struggling with few more topics - setting metering mode (spot, center, multi), setting white balance tint (green - purple axis as opposed to temperature yellow - blue). Is there way to control these parameters?

I'm integrating an Android app with our web experience and I'm finding a couple ways to launch my app with a given parameter foo via a link:

  1. <a href="intent://#Intent;package=com.example.app;S.foo=bar;end">click me</a>

  2. <a href="http://www.dummy.com/page.htm?foo=bar">click me</a>

and then in the manifest define an intent-filter

    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
        android:scheme="http" />

Example 1 will automatically launch the app in the marketplace if it is not already installed.

Example 2 I need to actually have a placeholder page page.htm to manage the not installed scenario.

Both will potentially work for my needs, both have their advantages and disadvantages, but is there a preferred/supported method? I'd hate to use an unsupported method that ends up failing to work in the future.

In my activity using tab for action bar, but what I try to do is when I'm in one of the options my tab, have a button in that fragment and click go to another activity, but I have an error on my Intent on which tells me that is not defined.

Someone can help me?

Thank you very much.

package com.example.dona1click;

import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Nosotros extends Fragment {
    Button Btn;
    Intent intent;

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View x = inflater.inflate(R.layout.nosotros, container, false);

        Btn = (Button)x.findViewById(R.id.button1);

        Btn.setOnClickListener(new OnClickListener() { // evento clic del boton

            public void onClick(View v) {

                // al hacer clic se manda para la otra pagina

                intent = new Intent (this, MainActivity.class);




        return x;

I'm having a somewhat strange problem. I created an ExpandableListView, an Adapter for it, and two objects to hold the data. The problem is that when I assign a v.onChildClickListener and then try to change the background color of the TextView it changes the background on several of them.

Here's the List header:

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

        android:layout_gravity="center_vertical" />


Here's the List Item:

<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"

    <TextView android:id="@+id/end_trip_item_address"
        android:text="Sample Data"


    <TextView android:id="@+id/end_trip_date_time"
        android:text="Sample Data 2"

        android:paddingLeft="2dp" />


Here's the List Group container object:

public class ExpandListGroup {
    private String name;
    private ArrayList<ExpandListChild> items;
    private int group_id = -1;

    public ExpandListGroup(int group_id) {
        this.group_id = group_id;
        items = new ArrayList<ExpandListChild>();

    public String getName() {
        return name;

    public int getGroupId() {
        return group_id;

    public void setName(String name) {
        this.name = name;

    public ArrayList<ExpandListChild> getItems() {
        return items;

    public void addItem(ExpandListChild item) {

    public void reverseChildren() {

Here's the List Item Object:

public class ExpandListChild {

    private String date = null;
    private long millis = -1;
    private int id = -1;
    private double distance = -1;
    private int tripKey = -1;
    private double lat = -1;
    private double lon = -1;
    private int businessRelated = -1;
    private String address = null;

    public ExpandListChild(String date, long millis, int id, double distance, int tripKey, double lat, double lon, int businessRelated, String address) {
        this.date = date;
        this.millis = millis;
        this.id = id;
        this.distance = distance;
        this.tripKey = tripKey;
        this.lat = lat;
        this.lon = lon;
        this.businessRelated = businessRelated;
        this.address = address;

    public String getDate() {
        return date;

    public int getId() {
        return id;

    public double getDistance() {
        return distance;

    public int getTripKey() {
        return tripKey;

    public double getLat() {
        return lat;

    public double getLon() {
        return lon;

    public int isBusinessRelated() {
        return businessRelated;

    public void setBusinessRelated(int businessRelated) {
        this.businessRelated = businessRelated;

    public String getAddress() {
        return address;

Now, here's the ListAdapter:

public class ExpandableListAdapter extends BaseExpandableListAdapter {

    private Context context;
    private ArrayList<ExpandListGroup> groups;

    public ExpandableListAdapter(Context context, ArrayList<ExpandListGroup> groups) {
        this.context = context;
        this.groups = groups;

    public int getGroupCount() {
        return this.groups.size();

    public int getChildrenCount(int groupPosition) {
        ArrayList<ExpandListChild> children = groups.get(groupPosition).getItems();
        return children.size();

    public Object getGroup(int groupPosition) {

        return groups.get(groupPosition);

    public Object getChild(int groupPosition, int childPosition) {
        ArrayList<ExpandListChild> children = groups.get(groupPosition).getItems();
        return children.get(childPosition);

    public long getGroupId(int groupPosition) {
        return groupPosition;

    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;

    public boolean hasStableIds() {
        return true;

    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        ExpandListGroup group = (ExpandListGroup)getGroup(groupPosition);
        String headerTitle = group.getName();

        if (convertView == null) {
                LayoutInflater inflater = (LayoutInflater) context
            convertView = inflater.inflate(R.layout.trip_expand_header, null);

        TextView lblListHeader = (TextView) convertView
        lblListHeader.setTypeface(null, Typeface.BOLD);

        return convertView;

    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {

        ExpandListChild child = (ExpandListChild)getChild(groupPosition, childPosition);

        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) context
            convertView = inflater.inflate(R.layout.trip_list_item, null);

        TextView addressView = (TextView) convertView

        TextView dateView = (TextView) convertView

        return convertView;

    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;


Finally, here's where I set the adapter and where I try to change the background of the TextView. It's also where the weirdness happens where when I touch one item it changes the background of that item as well as what seems to be randomly changing the background of other items.

listAdapter = new ExpandableListAdapter(this, listGroups);


        expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
                public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {

                    TextView text = (TextView)v.findViewById(R.id.end_trip_item_address);

                    return false;

I am facing issue to discover ChromeCast devices, i need to enable Debug mode for MediaRouter.

I have not found any option on the documentationof android.support.v7.media.MediaRouter.

Is it possible?

I have been trying to explore the Evernote API - https://dev.evernote.com/doc/. When a business card is scanned in evernote, it stores the email, phone no etc. I am unable to find the calls from the API that would return back that info for me. Let me know how to return that information from an evernote note.


I'm not sure how I would go about declaring the timer1 instance of my subclass Timer. I'm told I need to initialize the instance but how do I do that if timer1 is a class instance and not a primitive? Here's my code:

package com.example.derpphone;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.net.SocketException;
import java.util.TimerTask;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

public class MainActivity extends Activity implements OnClickListener{

public class Timer extends TimerTask {

DatagramSocket socket;

public Timer() throws SocketException { 
    this.socket = new DatagramSocket();

    public void run() {     
        while (true){
                if (socket != null) {
                                   byte[] bytes = new byte[100];
                    SocketAddress serverAddress = new InetSocketAddress("", 9998);
                    try {
                        DatagramPacket packet = new DatagramPacket(bytes,
                                bytes.length, serverAddress);

                    } catch (Exception e) {

    Timer timer1;
 public MainActivity () throws SocketException{
 timer1 = new Timer();

String error = "error";

protected void onCreate(Bundle savedInstanceState) {

    View callButton = findViewById(R.id.btnCall);


private void phoneCall()
   String phoneCallUri = "tel://myPhoneNumber";
   Intent phoneCallIntent = new Intent(Intent.ACTION_CALL);
 public void onClick(View view) {
       case R.id.btnCall:

       case R.id.end:


I am new in android programming so i take the error of "catchable fatal error object of class stdclass could not be converted to string " from my virtual device. and the error line in php class is below. Thanks for your answers.

PHP Code:

$friendlocs= $db->getFriendsLocations($useremail);


if ($res){
while ($row = mysql_fetch_array($friendlocs))
            //$b["id"] = $data[$j]->id;

            $b["f_name"] = "_";
            $b["f_email"] = $row[0];
            $b["f_lat"] = $row[1];
            $b["f_lon"] = $row[2];
            $b["f_time"] = $row[3];
            $b["f_timezone"] = $row[4];
            $b["f_synctime"] = $row[5];
            $b["f_friend_status"] = $row[6];



 print json_encode($a);

PHP function:

    public function getFriendsLocations($user_email) {
    // birden fazla row döndüreceği için ANY ifadesi kullanılarak birleştiriliyor.
        $result = mysql_query("select user_email,and_loc_lat, and_loc_long, and_loc_time, and_loc_timezone, and_sync_time, user_loc_status FROM tbl_currentlocs WHERE user_email = ANY (select DISTINCT friend_email FROM tbl_friendship WHERE user_email = '$user_email')");
    return $result;

Android code:

                    try {
                            JSONArray arr = new JSONArray(response);
                            System.out.println("try başladı");
                            for(int i=0; i<arr.length();i++){
                                System.out.println("for başladı");
                                JSONObject obj = (JSONObject)arr.get(i);

                                     friendDb.updateFriendLocSyncStatus(obj.get("f_name").toString(), obj.get("f_email").toString(), obj.get("f_lat").toString(), obj.get("f_lon").toString(), obj.get("f_time").toString(), obj.get("f_timezone").toString(), obj.get("f_friend_status").toString(), obj.get("f_synctime").toString() );
                            Toast.makeText(getApplicationContext(), "Friend Location Sync completed!", Toast.LENGTH_LONG).show();
                        } catch (JSONException e) {
                            // TODO Auto-generated catch block
                            Toast.makeText(getApplicationContext(), "Error Occured [Server's JSON response might be invalid]!", Toast.LENGTH_LONG).show();

i'm new to java,i try to get specified value from table in my geodatabase file

this my code when i call my geodatabase file

final String extern = Environment.getExternalStorageDirectory().getPath();
final String geo_kntr = "/ArcGIS/samples/localtilelayer/routing/kontur_444.geodatabase";
        try {
            g_kontur = new Geodatabase(extern + geo_kntr);
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
        gft_kontur = g_kontur.getGeodatabaseFeatureTableByLayerId(0);
        fl_kontur = new FeatureLayer(gft_kontur);

and i confuse how to get specified value from there,i've tried to solve this but still have no clue..

i'm so sorry for my bad english

Hie guys (better yet, coders), I'v this use case :

open app > game starts with user's turn > He got to enter a country in Edittext & click on submit button before 20 seconds else num_of_faults will increase by 1 (if(num_of_faults == 3) game_over)

now semi pseudo code is :

static void Game(){
            if(condition 1 is false){
            } else {
                continue game;          
            if(num_of_faults == max_tries){
        if(num_of_faults == max_tries){

public static void getTimedInput(){
    final Thread thread=  new Thread(){
        public void run(){
            try {
            catch(InterruptedException ex){                    

   inputSubmit.setOnClickListener(new OnClickListener() {           
        public void onClick(View v) {
            get editText input some input validations..           

            if(condition 2 is false){ 
            } else if(condition 3 is false) {
            } else {
                continue game;

it indeed is possible duplicate of "waiting for user to click a button" on stack overflow, But i'v spent many all nighters trying to solve this, PS : can't really seem to put whole code in onClickListener, i'hd really appreciate if ne1 could really put some effort in solving abovmentioned logic, or at least give me some pointers to work upon. Thanks!

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.