I have tabs in my webview, and I want to map the each tab in the webview to android tab. (I have done this already, except I now have 2 tab-views, 1 android tab, 1 webview tab)

Webview's tab is hidden when user scroll down and shown when user scroll up, and I don't know how to do that with android tabs. (I don't know if it's possible)

Hiding the android tab will work perfectly for me. But setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD) disables tab functionality. (e.g. setSelectedNavigationItem() doesn't work when in STANDARD mode)

Can I somehow hide the tab but keep the tab functionality at the same time?

I have a php script that makes a few api calls in a row and once an api call has returned data the script outputs the content. Meaning if you call the script on the browser you will wait 1 second then see some content appear, than after 2 seconds more content will be appended to the page and so on.

The thing is I am accessing this content from java/android in one of my apps. Is there a way I can read this content from java WHILE it is updating? This way I will populate the application content as new data is being fetched from the script.

I have tried something like this when I have accessed xml files but they were not continuously updating.

try {
    // defaultHttpClient
    DefaultHttpClient httpClient = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost(url);

    HttpResponse httpResponse = httpClient.execute(httpPost);
    HttpEntity httpEntity = httpResponse.getEntity();
    xml = EntityUtils.toString(httpEntity);

}

Thank you.

I am quite new to this topic, so maybe i have the wrong thinking. But please help me ;) The only think i want to see is a normal map of my location with the public transport stops and lines next to me. But i only get a black screen with the public transport data.

I thought the public transport tile has the mapnik tile as background.

 @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mapactivity);
    final MapView mapView = (MapView) findViewById(R.id.mapview);

    mapView.setBuiltInZoomControls(true);
    mapView.setMultiTouchControls(true);
    mapView.getController().setZoom(16);
    mapView.setUseDataConnection(true);

    ResourceProxy resourceProxy = new DefaultResourceProxyImpl(getApplicationContext());

   // mapView.getTileProvider().setTileSource(TileSourceFactory.MAPQUESTOSM);
   // mapView.getTileProvider().setTileSource(TileSourceFactory.MAPNIK);
       mapView.getTileProvider().setTileSource(TileSourceFactory.PUBLIC_TRANSPORT);

    myLocationOverlay = new MyLocationNewOverlay(this, mapView);
    mapView.getOverlays().add(myLocationOverlay);
    myLocationOverlay.enableMyLocation();

    myLocationOverlay.runOnFirstFix(new Runnable() {
        public void run() {
            try {
                mapView.getController().animateTo(myLocationOverlay.getMyLocation());
            }
            catch (Exception e){}
        }
    });

}

If i change from the public transport tile to the mapnik or the mapquestosm tile, the app shows me a correct map. But how can i put the public transport data into it if not as a second tile?

I'm trying to embedding Google Maps on my android application, but the API throwing an "IOException: Server returned: 3", like this question: Android Google Maps API throwing server returned 3 with empty grids

I tried to follow these tips:

  1. Using Google Maps API v2? Yes and follow this steps: https://developers.google.com/maps/documentation/android/start

  2. Is APK signed? Signer with debug certificate yet, generate the API KEY right here: https://console.developers.google.com/ and using SHA-1 fingerprint showing in eclipse (preferences -> Android -> Build -> SHA1 Fingerprint)

If anyone can help, i will appreciate

My AndroidManifest.xml:

  1. My permissions and features:

    <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" />
    <!-- Location -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    
    <!-- OpenGL for Google Maps -->
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />
    
  2. Useful details in "application" tag:

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_iconlauncher"
        android:label="@string/app_name"
        android:theme="@style/customActionBarTheme"
        android:hardwareAccelerated="true">
        <uses-library android:name="com.google.android.maps" />
    
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="@string/api_key_gmaps" />
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        [...]
    </application>
    

In my layout definition:

<com.google.android.maps.MapView
    android:id="@+id/mapview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/navigationBottom"
    android:apiKey="@string/api_key_gmaps"
    android:clickable="true" />

i am implementing autocomplete places for my app however it is not working when i am giving space as input i have checked my url it is encoding " " with + i have checked the url from browser its giving response but in android it is not giving response https://maps.googleapis.com/maps/api/place/autocomplete/json?sensor=true&input=kr+puram&types=geocode&key="my server key "

i am getting reponse in browser but in my android it is not giving any response

please help me to solve this problem

Earlier I asked to get the address of specific coordinates. Now I want to parse the JSON structure which can be received with URL https://maps.google.com/maps/api/geocode /json?latlng=48.906233407932675,2.433183006942272 I used the following code, but this causes a crash of my application.

public void parseJSONLocation(LatLng point)
{
    Toast.makeText(getApplicationContext(), "Test", Toast.LENGTH_LONG).show();
    double lat = point.latitude;
    double lng = point.longitude;

    JSONObject ret = getJSONLocationInfo(lat, lng);
    JSONObject location;
    String location_string = "";

    try {

        //Get JSON Array called "results" and then get the 0th complete object as JSON        
        location = ret.getJSONArray("results").getJSONObject(0); 
        // Get the value of the attribute whose name is "formatted_string"
        location_string = location.getString("formatted_address");
        //Toast.makeText(getApplicationContext(), "formattted address:" + location_string, Toast.LENGTH_LONG).show();
    } catch (JSONException e1) {
        e1.printStackTrace();

    }
}

public JSONObject getJSONLocationInfo(double lat, double lng)
{
    HttpGet httpGet = new HttpGet("http://maps.googleapis.com/maps/api/geocode/json?latlng=" + lat + "," + lng + "&key=AIzaSyB3hYTOGwj2FM9rSCYxTag1VkJXpFRmkOc");
    HttpClient client = new DefaultHttpClient();
    HttpResponse response;
    StringBuilder stringBuilder = new StringBuilder();

    try {
        response = client.execute(httpGet);
        HttpEntity entity = response.getEntity();
        InputStream stream = entity.getContent();
        int b;
        while ((b = stream.read()) != -1) {
            stringBuilder.append((char) b);
        }
    } catch (ClientProtocolException e) {
        } catch (IOException e) {
    }

    JSONObject jsonObject = new JSONObject();
    try {
        jsonObject = new JSONObject(stringBuilder.toString());
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return jsonObject;
}

Does anyone has an idea to solve this?

i am having few counter variables that i need to store for their values even when that app is closed or kill or rotated.i know about savedinstancestate,but i dont know how to use it.here's my code i want to save the following values of the variables 1.allahuakbarweek 2.allahuakbarmonth 3.subhanallahweek 4.subhanallahmonth 5.alhamdulilahweek 6.alhamdulilahmonth

here's my code it is a fragment

    package com.farme5.mosquelocator;





import android.os.Bundle;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
 import android.text.format.Time;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView; 

    public class FragTasbeeh extends Fragment  {

    private Spinner spinner;
    public static final String[] items={"Alhamdulilah","SubhanAllah","AllahuAkbar"};
    ImageView ivIcon;
       TextView tvItemName;
       TextView mview;
       TextView wview;
      Button add,reset;
        int counter=0;
        int week,allahuakbarweek,allahuakbarmonth,subhanallahweek,subhanallahmonth,alhamdulilahweek,alh amdulilahmonth;
        int month;
        int count,alhamdulilahcount,subhanallahcount,allahuakbarcount;
    Time t=new Time(Time.getCurrentTimezone());

    public static final String IMAGE_RESOURCE_ID = "iconResourceID";
    public static final String ITEM_NAME = "itemName";
      FragmentManager frg=getFragmentManager();
      Fragment fragment=null;

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

        View view=inflater.inflate(R.layout.tasbeeh,container, false);
        if(savedInstanceState==null)
        {
            alhamdulilahcount=0;
            alhamdulilahweek=0;
            alhamdulilahmonth=0;
        }
        else
        {

            savedInstanceState.putInt("alhamdulilahcount", alhamdulilahcount);
            savedInstanceState.putInt("alhamdulilahweek", alhamdulilahweek);
            savedInstanceState.putInt("alhamdulilahmonth", alhamdulilahmonth);
        }

        return view;

    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onActivityCreated(savedInstanceState);
        add=(Button)getActivity().findViewById(R.id.button1);
        tvItemName=(TextView)getActivity().findViewById(R.id.textView1);
        wview=(TextView)getActivity().findViewById(R.id.textView2);
        mview=(TextView)getActivity().findViewById(R.id.textView3);

        Spinner dropdown = (Spinner)getActivity().findViewById(R.id.spin);

        ArrayAdapter<String> adapter = new ArrayAdapter<String> (this.getActivity(),android.R.layout.simple_spinner_item, items);
            dropdown.setAdapter(adapter);
            dropdown.setOnItemSelectedListener(new OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1,
                    int position, long arg3) {
                // TODO Auto-generated method stub
                switch(position){

                case 0: 

                    tvItemName.setText(alhamdulilahcount+"");
                    mview.setText(alhamdulilahmonth+"");
                    wview.setText(alhamdulilahweek+"");
                alhamdulilahcount();
                break;
                case 1:
                    tvItemName.setText(subhanallahcount+"");
                    mview.setText(subhanallahmonth+"");
                    wview.setText(subhanallahweek+"");
                    subhanallahcount();
                    break;
                case 2:
                    tvItemName.setText(allahuakbarcount+"");
                    mview.setText(allahuakbarmonth+"");
                    wview.setText(allahuakbarweek+"");
                    allahuakbarcount();
                    break;
                    default:
                        break;
                }

            }

            private void allahuakbarcount() {
                // TODO Auto-generated method stub
                count=0;
                month=0;
                week=0;
                add = (Button)getActivity().findViewById(R.id.button1);
                reset = (Button)getActivity().findViewById(R.id.button2);
                reset.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        // TODO Auto-generated method stub
                        allahuakbarcount=0;
                        tvItemName.setText(allahuakbarcount+"");

                    }
                });
                add.setOnClickListener(new OnClickListener() {


                    @Override
                    public void onClick(View v) {
                        // TODO Auto-generated method stub

                        allahuakbarcount++;
                week++;
                        month++;
                        allahuakbarweek++;
                        allahuakbarmonth++;
                        tvItemName.setText(allahuakbarcount+"");
                        mview.setText(allahuakbarmonth+"");
                        wview.setText(allahuakbarweek+"");


                    }
                });
            }

            private void subhanallahcount() {
                // TODO Auto-generated method stub

                count=0;
                add = (Button)getActivity().findViewById(R.id.button1);
                reset = (Button)getActivity().findViewById(R.id.button2);
                reset.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        // TODO Auto-generated method stub
                        subhanallahcount=0;
                        tvItemName.setText(subhanallahcount+"");

                    }
                });
                add.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        // TODO Auto-generated method stub
                        subhanallahcount++;
                        week=week+count;
                        month=month+count;
                        subhanallahweek++;
                        subhanallahmonth++;

                        tvItemName.setText(subhanallahcount+"");
                        mview.setText(subhanallahmonth+"");
                        wview.setText(subhanallahweek+"");



                    }
                });
            }

            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
                // TODO Auto-generated method stub

            }
        });         }





    public  void alhamdulilahcount() {
        // TODO Auto-generated method stub
        alhamdulilahcount=0;
        add = (Button)getActivity().findViewById(R.id.button1);
        reset = (Button)getActivity().findViewById(R.id.button2);
        reset.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                alhamdulilahcount=0;
                tvItemName.setText(alhamdulilahcount+"");

            }
        });
        add.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                alhamdulilahcount++;
                week++;
                month++;
                alhamdulilahweek++;
                alhamdulilahmonth++;
                tvItemName.setText(alhamdulilahcount+"");
                mview.setText(alhamdulilahmonth+"");
                wview.setText(alhamdulilahweek+"");


            }
        });

    }


    /* (non-Javadoc)
     * @see android.app.Fragment#onSaveInstanceState(android.os.Bundle)
     */
    @Override
    public void onSaveInstanceState(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onSaveInstanceState(savedInstanceState);
        savedInstanceState.putInt("alhamdulilahcount", alhamdulilahcount);
        savedInstanceState.putInt("alhamdulilahweek", alhamdulilahweek);
        savedInstanceState.putInt("alhamdulilahmonth", alhamdulilahmonth);
    }
    }

How can i scan my android app for potential security vulnerabilities that can cause damage to my users & company in an affordable cost?

I am trying to send the bundle data from the activity class to the fragment class, but I have been getting the NPE error. I've researched a bit on Stackoverflow and tried a few different things, but none seemed to work.

I have another activity class sending the intent to the MainActivity class. So the bundle from the MainActivity.java is definitely not null when it is sent to the myFragment class.

Please help! Thank you! :D

MainActivity.java

public class MainActivity extends FragmentActivity {

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

      Bundle extras = getIntent().getExtras();
      if (extras != null) {
        Bundle bundle = new Bundle();
        String value = extras.getString("TEST36");
        bundle.putString("TEST36", value);
        myFragment fragInfo = new myFragment();
        fragInfo.setArguments(bundle);
      }
  }
}

myFragment.java

public class myFragment extends Fragment{
   @Override
   public View onCreateView(LayoutInflater inflater, ViewGroup parent,
        Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_xml, parent, false);

   @Override
   public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Bundle bundle = getArguments();                                             
    String myMode = bundle.getString("TEST36");
   }
 }

I've installed

  • Android SDK
  • Apache Ant
  • Phonegap (via node.js)
  • (all in Windows 7)

Unfortunately I had an old version from the Android SDK & Apache Ant on my PC. Now I have the problem everytime I run

phonegap run myProjectName

it says this

...
Buildfile: D:\Dev\Apps\testApp\platforms\android\build.xml
  [taskdef] Could not load definitions from resource emma_ant.properties. 
            It could not be found.

-set-mode-check:
-set-debug-files:
-check-env:
  [checkenv] Android SDK Tools Revision 23.0.0
  [checkenv] Installed at D:\Software\ADT\sdk

BUILD FAILED
D:\Software\ADT\sdk\tools\ant\build.xml:483: The SDK Build Tools revision (17.0.0)is too low for project 'HelloWorld'. Minimum required is 19.1.0

In my new installation of the Android SDK the folder is now

D:\Dev\ADT  // --> not D:\Software\ADT

I changed the windows ENVIROMENTS: PATH, ANT_HOME, ANDROID_HOME. But Phonegap always says that the SDK is installed in that old folder.

What else have I to change here? I can't find it. Phonegap seems to read some configuration I haven't found yet. Because the problem occurs while run Phonegap. I deleted Phonegap and installed it again but that doesn't fix the problem. So I guess somewhere in windows has to be a config that hold this SDK.DIR with the old values.

In my android app, I have a tableLayout which I want to expand/collapse. I tried many solutions from many stackoverflow pages, but none work great.

I found this site, which gives the best solution, but its still not perfect. When I expand or collapse, you see the view for 1 frame in a totally random place (blink of an eye)...

http://softsoulandroid.wordpress.com/2012/01/21/android-view-expandcollapse-animation/

This is the code I have so far

package animation;

import java.lang.reflect.Method;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.animation.Animation;
import android.view.animation.Transformation;

public class Animate {

    public static Animation expand(final View v, final boolean expand) {
        try {
            Method m = v.getClass().getDeclaredMethod("onMeasure", int.class,int.class);
            m.setAccessible(true);
            m.invoke(v,MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
                MeasureSpec.makeMeasureSpec(((View) v.getParent()).getMeasuredWidth(),MeasureSpec.AT_MOST));
        } catch (Exception e) {
            e.printStackTrace();
        }

        final int initialHeight = v.getMeasuredHeight();
        if (expand) {
            v.getLayoutParams().height = 0;
        } else {
            v.getLayoutParams().height = initialHeight;
        }
        v.setVisibility(View.VISIBLE);

        Animation a = new Animation() {
            @Override
            protected void applyTransformation(float interpolatedTime, Transformation t) {
                int newHeight = 0;
                if (expand) {
                    newHeight = (int) (initialHeight * interpolatedTime);
                } else {
                    newHeight = (int) (initialHeight * (1 - interpolatedTime));
                }
                v.getLayoutParams().height = newHeight;
                v.requestLayout();
                if (interpolatedTime == 1 && !expand) {
                    v.setVisibility(View.GONE);
                }
            };

            @Override
            public boolean willChangeBounds() {
                return true;
            }
        };

        a.setDuration(500);
        return a;
    }
}

and code to call it

    toggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
            //table.setVisibility(arg1 ? View.VISIBLE : View.GONE);

            Animation anim = Animate.expand(table, arg1);
            table.startAnimation(anim);
        }
    });

Does anyone know what is wrong and how to fix it?

Thanks

This is a class which extends Thread and implements the run() function:

public class TestThread extends Thread{
public Handler handler;
public TestThread(){

    handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            // TODO Auto-generated method stub
        }
    };
}
public Looper getLooper(){
    return Looper.myLooper();
}
@Override
public void run() {
    // TODO Auto-generated method stub
        Looper.prepare();
        Looper.loop();      
}
}

Now in a button in the main activity I have this code:

TestThread t=new TestThread();
    t.start();  
    Handler h=new Handler(t.getLooper());
    h.post(new Runnable(){
        @Override
        public void run() {
            // TODO Auto-generated method stub
            while (true);
        }
    });

As far as I know this is supposed to put the runnable in the target Thread's message queue and the thread (not UI thread) will run it when possible. But this code blocks the UI. why does this happen? As you see I sent the target thread's looper to the Handler constructor and the handler should use that looper not the main thread's looper.

I want to capture the screen. Libgdx provides some functions defined in the ScreenUtils class.

For instance final Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(x, y, w, h);

My problem is that it takes about 1-3 seconds to get that information. During that time the game loop is blocked and the user will define it as a lag.

Internally the ScreenUtils class, uses Gdx.gl.glReadPixels. If I run the ScreenUtils.getFrameBufferPixmap method in a thread, there is no lag, but it captures the screen at the wrong method, which is logical since the game loop runs and changes stuff.

Is it somehow possible to copy the GL context or save it and generate the Pixmap at a later point of time with the help of a Thread? Of course the copy/save operation should be done instantly, otherwise I don't spare anything.

I use ShapeRenderer to render my stuff onto the screen.

I am using SoundPool in order to play some sounds using timers in my applications. Does anyone know if there is an in-built queue where it will queue files and play them only when the previous files are finished?

Do I have to write my own implementation of a SoundPool queue?

My events management app has two types of views in the list view : a small simmple text view for not-so-important events and a complex view created with a FrameLayout.

in the onCreateView() of the adapter, I return these views depending upon the nature of the event.

if(convertView == null){
  if(important)
   // inflate the complex view
  else
   // inflate the simpler view
}  

This is all good when convertView is null. Due to the view recycling in Android, it may happen that the convertView returned to me is recycled from the simpler view and I now have to display the larger view. One dumb solution is to inflate new views all the time. However, this will kill performance.

Another way is to have invisible TextViews in both of them (visibility=gone) with predefined values and depending on what value is in them, I can inflate the views. To me, this seems like a hack rather than a real solution.

What is the right way to handle this situation?

I want to make an app allow user to set a time on which message has been send please help me what to do and how to do am done with text boxes and buttons and I am able to send message too but I don't know how to get device time and time from user to use if statement for message send

first after finishing by app i want to add AD to my app before i but it in google play , i use this to do it https://developers.google.com/mobile-ads-sdk/docs/ to do this i have to update my sdk , and after that i start getting problem trying to install the ADT first it cant found the update second after i get how to do it they asked me to go to Help/ Install new software and then what is already install and uninstall all the 22.0 . but after i uninstall it and before i install the new 23.0 when i try to open the eclips it give me this error the eclipse executable launcher was unable to locate its companion shared library
i download new ADT and try to instill the 23.0 i got this error

No repository found containing: org.eclipse.update.feature,com.android.ide.eclipse.adt.feature,23.0.2.1259578



Details: An error occurred while collecting items to be installed

session context was:(profile=DefaultProfile, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=). No repository found containing: org.eclipse.update.feature,com.android.ide.eclipse.adt.feature,23.0.2.1259578 No repository found containing: org.eclipse.update.feature,com.android.ide.eclipse.ddms.feature,23.0.2.1259578 No repository found containing: org.eclipse.update.feature,com.android.ide.eclipse.gldebugger.feature,23.0.2.1259578 No repository found containing: org.eclipse.update.feature,com.android.ide.eclipse.hierarchyviewer.feature,23.0.2.1259578 No repository found containing: osgi.bundle,com.android.ide.eclipse.ndk,23.0.2.1259578 No repository found containing: org.eclipse.update.feature,com.android.ide.eclipse.ndk.feature,23.0.2.1259578 No repository found containing: org.eclipse.update.feature,com.android.ide.eclipse.traceview.feature,23.0.2.1259578

ok i selove the last thing and update to 23.0 in the new ADT that i install my error was in http change it to https no i get this error in this IMG

IMG

ok i fix this also by right click on my app then properties then i choose project build target as android 4.4w but i get one new error is in all case .. case expressions must be constant expressions and .. import android.support.v7.appcompat.R.id; ... The import android.support.v7.appcompat.R cannot be resolved why nothing is working for me . my app was already done :(

I want to use a layout and not a drawable for my marker I am using with Google Maps Api 2 for an Android app.

Like this:

  Marker m = googleMap
                        .addMarker(new MarkerOptions()
                                .position(LOC)
                                .snippet(user)
                                .title(name)
                                .icon(BitmapDescriptorFactory.fromResource(R.layout.map_marker)));

However, it seems this is only designed for use from drawable folder.

I simply what an image with a background where I can change colors based on marker type. This is the layout I want to use:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:background="#222"
    android:id="@+id/llMarker">

    <ImageView
        android:id="@+id/ivMarker"
        android:layout_marginTop="5dp"
        android:layout_width="40dp"
        android:layout_height="40dp" />

</LinearLayout>

Pretty basic. How can I use this as a marker? (or at least replicate the end result that I am going for?)

The documents say you can use this:

fromResource (int resourceId)

So I assumed a layout might work.

I want to make a phonegap android app which displays the live camera feed as the activity background. am a fairly experienced phonegap developer but i have totally novice when it come to mainstream android app development .does anybody have an idea how to go about this .

I have this code in an xml inside the drawable folder:

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

    <item android:state_pressed="true">
        <layer-list>
            <item>
                <shape android:shape="rectangle">
                    <size android:width="90dp" android:height="90dp" />

                <solid android:color="#9933CC" />
                </shape>
            </item>
            <item>
                <bitmap android:gravity="center" android:src="@drawable/main_achievements_synthesis" />
            </item>
        </layer-list>
    </item>
    <item>
        <layer-list>
            <item>
                <shape android:shape="rectangle">
                    <size android:width="90dp" android:height="90dp" />

                    <solid android:color="#AA66CC" />
                </shape>
            </item>
            <item>
                <bitmap android:gravity="center" android:src="@drawable/main_achievements_synthesis" />
            </item>
        </layer-list>
    </item>

</selector>

I use it to have an image with 2 states (to use as a button). Everything works as expected on emulator and devices.

I know that I can create different drawable xml and make a reference to achieve the same result.

I just switched to Android Studio and it shows me this mesage: Element XXX is not allowed here. It warns me about Layer-list and all the tags inside it. However, as I said, this code works just fine.

Should I switch my code into separated XMLs (knowing that I will only use them once) or is an "error" in the Android Studio's Inspector Code?

NOTE: I think my code can be optimized, but I haven't figured out how yet.

I'm creating a custom watch face and I would like to change the location of the battery icon on it. By default it is placed on the top left corner and I would like it to be positioned somewhere else on the taskbar.

Does anyone know how it can be done?