Friday, April 12, 2013

[android help] From BufferredImage to Byte[] without IO ---- failed


I am attempting to take continuous screenshots and stream them over a socket to my android phone. I used ImageIO for this like this:



while(true){
baos = new ByteArrayOutputStream();
ImageIO.write(screenshot, "png", baos);
byte[] imageArray = baos.toByteArray();
oos.writeInt(imageArray.length);
oos.write(imageArray);
oos.flush();
imageArray = null;
}


This worked fine, however, there was huge lag time in the pictures showing up on the phone, and I figured it was because of the ImageIO. so I looked around in stackoverflow for a solution to this, and found this method and tried it:



while(true){
//take screenshot of the screen periodically and send to the server
screenshot = robot.createScreenCapture(rectangle);
byte[] imageArray = ((DataBufferByte)screenshot.getRaster().getDataBuffer()).getData();
oos.writeInt(imageArray.length);
oos.write(imageArray);
oos.flush();
imageArray = null;
}


But this keeps giving me this exception:



Exception in thread "main" java.lang.ClassCastException: java.awt.image.DataBufferInt
cannot be cast to java.awt.image.DataBufferByte


Can someone please help?



.

stackoverflow.comm

[android help] Local Time to GMT/UTC Time


OK, I have a 2 time viewers (DigitalClock in Eclipse), sadly, in the same time zone (set to the phone). How would I change one of these to a UTC time?



.

stackoverflow.comm

[android help] How to use OpenGL ES 2.0? I just don't get it, Serious Q


This is a serious question, I am "stuck" at this point between understanding it and not at all. I got very confused with the time reading different resources and would like someone to point me in the right direction.


I am working with android platform, until now I have used the Canvas; some openGL ES 1.0, but mostly through engines or already built code to try and understand it.


My goal is to ACTUALLY understand OpenGL ES 2.0 . I do not want to go straight to the complicated stuff and start with easy stuff, but i just don't get how to do it. I can get a square, and I can set up a camera and matrices; to tell you the truth I really don't understand the whole matrix system and how it works, if I am right it was a fixed pipeline which you didn't need to change in openGL ES 1.0 but not it's an open pipeline which you have to set up on your own.


I do not get how to use the coordinate system, I know that the origin is the center of the device and each turn to the edge is 1, so from center to left it would be negative 1.


There were some ways however to make it into a different coordinate system, maybe just use proportions or multiply matrices to set the coordination to something that i was used to from the canvas.


Basically what I need help with is how do I progress from here? I feel as if I got to somewhere, but I am still nowhere.


I really need some advises on how to properly use OpenGL ES 2.0, for now all i am planning on is a simple 2d game, maybe side scroller too so i will have to mess with the camera matrices.


Thank you for your time, I will greatly appreciate any help.


*i am less interested in the transformation matrices since i do not think that 2d game would really use that, maybe only when i mirror the character's sprite so it would look as if he is walking the different direction, but im pretty sure this is possible to be made simple by changing the coordination and width.



.

stackoverflow.comm

[android help] Android create four buttons with even weight distribution programmatically


I am having major issues getting my program to properly display 4 buttons, side by side, with the same width. I have tried a bunch of combinations, and spent over an hour on StackOverflow searching solutions, with no luck on any of them. How can I go about making these four buttons all with the same height in the same row on a vertical interface?


This is what I have so far with no luck. Either buttons too large, too small, or are hidden since width 0.



protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
layout.setWeightSum(1);

Button redButton = new Button(this);
redButton.setText("Red");
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
0,
LayoutParams.WRAP_CONTENT,
0.25f);
redButton.setWidth(0);
redButton.setLayoutParams(p);
layout.addView(redButton);

Button greenButton = new Button(this);
greenButton.setText("Green");
greenButton.setLayoutParams(p);
greenButton.setWidth(0);
layout.addView(greenButton);

Button blueButton = new Button(this);
blueButton.setText("Blue");
blueButton.setLayoutParams(p);
blueButton.setWidth(0);
layout.addView(blueButton);

Button yellowButton = new Button(this);
yellowButton.setText("Yellow");
yellowButton.setLayoutParams(p);
yellowButton.setWidth(0);
layout.addView(yellowButton);

setContentView(layout);
}


.

stackoverflow.comm

[android help] How to add class with listview to a viewpager


I'm very new to Android, so forgive me if this is a terrible question, but I've searched high and low and I've been reading lots of material and can't seem to figure this out. I've created an app in Eclipse using one of the default views (fixed tabs + swipe). I created a second class with a listview and I'm trying to add this class to load in one of the tabs.


EDIT to include full MainActivity.java



package com.sonnyparlin.gracietampa;

import java.util.Locale;
import android.app.ActionBar;
import android.app.FragmentTransaction;
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.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class MainActivity extends FragmentActivity implements
ActionBar.TabListener {

SectionsPagerAdapter mSectionsPagerAdapter;

/**
* The {@link ViewPager} that will host the section contents.
*/
ViewPager mViewPager;

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

// Set up the action bar.
final ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

// Create the adapter that will return a fragment for each of the three
// primary sections of the app.
mSectionsPagerAdapter = new SectionsPagerAdapter(
getSupportFragmentManager());

// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);

// When swiping between different sections, select the corresponding
// tab. We can also use ActionBar.Tab#select() to do this if we have
// a reference to the Tab.
mViewPager
.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
});

// For each of the sections in the app, add a tab to the action bar.
for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
// Create a tab with text corresponding to the page title defined by
// the adapter. Also specify this Activity object, which implements
// the TabListener interface, as the callback (listener) for when
// this tab is selected.
actionBar.addTab(actionBar.newTab()
.setText(mSectionsPagerAdapter.getPageTitle(i))
.setTabListener(this));
}
}

@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 void onTabSelected(ActionBar.Tab tab,
FragmentTransaction fragmentTransaction) {
// When the given tab is selected, switch to the corresponding page in
// the ViewPager.
mViewPager.setCurrentItem(tab.getPosition());
}

@Override
public void onTabUnselected(ActionBar.Tab tab,
FragmentTransaction fragmentTransaction) {
}

@Override
public void onTabReselected(ActionBar.Tab tab,
FragmentTransaction fragmentTransaction) {
}

/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages.
*/
public class SectionsPagerAdapter extends FragmentPagerAdapter {

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

@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a DummySectionFragment (defined as a static inner class
// below) with the page number as its lone argument.
Fragment fragment = new DummySectionFragment();
Bundle args = new Bundle();
args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, position + 1);
fragment.setArguments(args);
return fragment;
}

@Override
public int getCount() {
// Show 3 total pages.
return 3;
}

@Override
public CharSequence getPageTitle(int position) {
Locale l = Locale.getDefault();
switch (position) {
case 0:
return getString(R.string.title_section1).toUpperCase(l);
case 1:
return getString(R.string.title_section2).toUpperCase(l);
case 2:
return getString(R.string.title_section3).toUpperCase(l);
}
return null;
}
}

/**
* A dummy fragment representing a section of the app, but that simply
* displays dummy text.
*/
public static class DummySectionFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
public static final String ARG_SECTION_NUMBER = "section_number";

public DummySectionFragment() {
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView;

if (getArguments().getInt(ARG_SECTION_NUMBER) == 1) {
rootView = inflater.inflate(R.layout.fragment_main_dummy,
container, false);
TextView dummyTextView = (TextView) rootView
.findViewById(R.id.section_label);
dummyTextView.setText(Html.fromHtml(getString(R.string.page1text)));
} else if (getArguments().getInt(ARG_SECTION_NUMBER) == 2) {


// I want to add my listview here


} else {
rootView = inflater.inflate(R.layout.fragment_main_dummy,
container, false);
TextView dummyTextView = (TextView) rootView
.findViewById(R.id.section_label);
dummyTextView.setText(Integer.toString(getArguments().getInt(
ARG_SECTION_NUMBER)));
}
return rootView;
}
}

}


My TechniqueActivity.java file:



public class TechniqueActivity extends ListActivity{

public TechniqueActivity() {
// TODO Auto-generated constructor stub
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// storing string resources into Array
String[] technique_list = getResources().getStringArray(R.array.technique_list);

// Binding resources Array to ListAdapter
this.setListAdapter(new ArrayAdapter(this, R.layout.list_item, R.id.label, technique_list));

}

}


I would really appreciate it if someone could point me in the right direction so that I can populate the second tab of my application with the listview I've created in TechniqueActivity.java. Or maybe there's a completely different / better way of doing it?



.

stackoverflow.comm

[android help] How to know "Don't keep activities" is enabled in ICS?


I agree with @Kaediil that android applications must work well while "Don't keep activities" option is checked.


Bu for some reason if you have to check "alwaysFinishActivities" value you can use code below;



/**
* returns true if AlwaysFinishActivities option is enabled/checked
*/
private boolean isAlwaysFinishActivitiesOptionEnabled() {
int alwaysFinishActivitiesInt = 0;
if (Build.VERSION.SDK_INT >= 17) {
alwaysFinishActivitiesInt = Settings.System.getInt(getApplicationContext().getContentResolver(), Settings.Global.ALWAYS_FINISH_ACTIVITIES, 0);
} else {
alwaysFinishActivitiesInt = Settings.System.getInt(getApplicationContext().getContentResolver(), Settings.System.ALWAYS_FINISH_ACTIVITIES, 0);
}

if (alwaysFinishActivitiesInt == 1) {
return true;
} else {
return false;
}
}


If alwaysFinishActivities option is checked and you want it to be unchecked;


You can direct user to "Settings -> Developer options" to uncheck that value. (This is better than to get extra scary permissions and set this value programatically)



/**
* shows Settings -> Developer options screen
*/
private void showDeveloperOptionsScreen(){
Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
}


.

stackoverflow.comm

[General] Memory Card problem


Are you sure you can download Spotify music to your external card? I'm not sure, but I'm guessing that with both apps, you can only download music to internal storage, not external, so it probably won't matter how big a card you insert.

Sent from my DROID RAZR using Android Central Forums



.

forum.xda-developers.com

[android help] How to load image thumbnail fast android?

caching - How to load image thumbnail fast android? - Stack Overflow




















I have a custom gallery in my app for which I'm using my own thumbnail directory. Here I'm caching the image thumbnail and storing it on my own sdcard directory and showing the thumbnail by loading it from custom image directory. It works well, but if it has more pictures it takes too long to load. Is there any way to load it faster and i don't use android's default thumbnail directory.





























I guess you are loading them on the main thread. Try using an AsyncTask to load each thumbnail. First check if the thumbnail is cached and return it. If not - download, cache and return.























Have you tried using something like Smart Image View?


It already caches an image and save to external (in case you are trying to get an image from a server, for example).


It also uses a thread pool executor, so you won't have problems with asynctask (like here).


But smart image view is just an example, there are lot's of projects out there.






















You can also try ImageLoader Library.


It caches images transparently with a two-level in-memory/SD card caching strategy. Images are fetched in a background thread, keeping your UI responsive.


There is also great documentation and a demo application.






















You can use AsyncTask to load image in dynamic drawable faster as you want.




















default







.

stackoverflow.comm

[General] help!


I have a galaxy s Blaze 4G and i recently have been having trouble with. When i put in my beats by dre ear buds, only my right bud plays audio while the left bud plays no audio! Any help ?



.

forum.xda-developers.com

[General] Hide mp3 files from Music player


I've dumped my thumb drive and now use my smartphone (HTC V One) for the same purpose. One side effect is I now have a couple directories full of mp3 files that I'd like to hide from the music player (no, they aren't those kinds of files. They're work related, not music).

Is it possible to hide directories from the music player? Even better, can I tell the music player to only look under 'My Music' on the SD card?



.

forum.xda-developers.com

[android help] How to install an Android application on a real device without publishing and Eclipse?

deployment - How to install an Android application on a real device without publishing and Eclipse? - Stack Overflow




















How can I install an application without any developer tools (Eclipse, Android SDK tools)?


I've compiled and created an .apk file. Now I am gonna send this apk file to my friend.


He is not an Android developer; he doesn't know how to use Eclipse or the SDK. And I don't want to publish my application to android market.


Is there a way to launch the application on a real device without publishing it or having access to a machine with the SDK?





























You can deploy the .apk file on your local server(apache or jboss) with a static IP to make the file available for download. Now just open the download link of the apk file in your mobile browser. The device will automatically start the installation after the download completes.























The way I usually do this is:


  1. Plug in my USB cable to my PC and mount my SD card on my computer

  2. Get the APK file somewhere on my SD card on the phone

  3. Unmount the SD card on my PC, allowing the phone to see the SD card contents again

  4. Use Astro File Manager or some similar app to browse to that file on the SD card and select it, which will prompt you if you want to install the app on your phone.





















You should set Settings -> Application -> Unknown sources to allow installation from non-Market. Then, once your application is published somewhere, you can download it an install it.






















Also you can use 'adb install ' to install apk's to your device.


Though this approach requires you to have adb available on your computer and adb is part of the sdk.


Another, easier approach, is using DropBox. This enables you to save the apk in the dropbox/public folder, create a URI from there and supply this to your friend. Then have him download the apk. Android will notify him when it's done, so he only has to click the notification and Android will ask him whether or not he wants to install this software.






















Hopefully you will find the answer from here Install Android application on Android Device


Add your APK file to your device SD card and run it, you must allow to install non-market application on your device before you going to install.


Go to Setting -> Application Setting ->Unknown Source and tick check box which will allow to install non-market application on your device






















Use DeployGate.


Just upload your app and share privately via distribution page. It will guide your friend to install your app and you can see how is going, e.g. which version is installed or updated, or app is crashed, in realtime.


Though it's a very common question, there were no simple way to achieve it. Even if we can send the apk via any way, we need to change the non-Market setting and get asked for help of this kind everyday. It's simply a hassle. So we made DeployGate, a tester-friendly private app distribution service to help the developers just like you ;)

























what i usually do is: 1. Through mail: i send the .apk to their mail id. 2. do open his mail in his mobile. and download the attached .apk. 3. it will ask for installation and do run.























default







.

stackoverflow.comm

[General] How do I listen to free music online on my tablet?


I mean free, legal music. Like on Youtube...it is too bad so many videos are blocked from being played on mobile devices. How else can I do this? And forget Pandora radio. It is good, but there is no way you can search for specific songs which is just stupid. Seriously somebody please help me out because this blasted tablet is the only computer I have, and I am a broke, and now very angry, student.



.

forum.xda-developers.com

[android help] java.lang.NoClassDefFoundError in android


I updated the Sherlock action bar library to new version in my project. After compiling and running logcat shows NoClassDefFoundError.


I have checked the jar versions. I have added the jars in project libs folder. I also checked order and export tab in build path. I also tried clean and build. Still i am getting NoClassDefFoundError.


My LogCat is shown below



E/AndroidRuntime(9699): java.lang.NoClassDefFoundError: com.mobiotics.tvbuddydemo.TVBuddyMainActivity
E/AndroidRuntime(9699): at com.mobiotics.tvbuddydemo.SplashScreen.onCreate(SplashScreen.java:54)
E/AndroidRuntime(9699): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime(9699): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
E/AndroidRuntime(9699): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
E/AndroidRuntime(9699): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
E/AndroidRuntime(9699): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
E/AndroidRuntime(9699): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(9699): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(9699): at android.app.ActivityThread.main(ActivityThread.java:3839)
E/AndroidRuntime(9699): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(9699): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(9699): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
E/AndroidRuntime(9699): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
E/AndroidRuntime(9699): at dalvik.system.NativeStart.main(Native Method)


THE error line in splash screen



TVBuddyMainActivity.setSuccess(false);


i cant figure out the cause earlier working fine


My MAINFEST




package="com.mobiotics.tvbuddydemo"
android:versionCode="1"
android:versionName="1.0" >
android:targetSdkVersion="15"
/>
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyTheme"
android:screenOrientation="portrait"
>
android:name=".SplashScreen"
android:label="@string/app_name"
android:screenOrientation="portrait"
>





android:name=".TVBuddyMain"
android:screenOrientation="portrait">





android:name=".CustomSearch"
android:screenOrientation="portrait"
>






android:name=".PackageBuilderActivity"
android:screenOrientation="portrait"
>

android:name="com.mobiotics.tvbuddy.data.service.Droid_service"
android:exported="false" />










.

stackoverflow.comm

[android help] Android AsyncTask: How to handle the return type


I am working on an Android application that executes an http POST request and the tutorial I followed was resulting in an android.os.NetworkOnMainThreadException


The original code was something like this



public class JSONParser {

static InputStream is = null;
static JSONObject jObj = null;
static String json = "";

// constructor
public JSONParser() {

}

public JSONObject getJSONFromUrl(String url, List params) {

// Making HTTP request
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));

HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();

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

try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
json = sb.toString();
Log.e("JSON", json);
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}

// try parse the string to a JSON object
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}

// return JSON String
return jObj;

}
}


And this class was invoked with this line



JSONObject json = jsonParser.getJSONFromUrl(loginURL, params);


After changing this to an AsyncTask class, the code looks like this



class JSONParser extends AsyncTask{

static InputStream is = null;
static JSONObject jObj = null;
static String json = "";

// variables passed in:
String url;
List params;

// constructor
public JSONParser(String url, List params) {
this.url = url;
this.params = params;
}

@Override
protected JSONObject doInBackground(String... args) {
// Making HTTP request
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));

HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();


} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}


try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
json = sb.toString();
Log.e("JSON", json);
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}

// try parse the string to a JSON object
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}

// return JSON String
return jObj;
}

@Override
protected void onPostExecute(JSONObject jObj) {
return;
}
}


My question is, how do I return a return a JSONObject from this new AsyncTask class. I can see that jObj is being returned in doInBackground() but I am not sure where it is being returned to.


What do I need to modify or how do I need to call my new JSONParser class so that it is returning a JSONObject?



.

stackoverflow.comm

[android help] How to add values of multiple edittexts in android?

How to add values of multiple edittexts in android? - Stack Overflow



















I am creating dynamic layout in my code. My UI has multiple rows which are dynamically created at runtime. Each row consists of single edit text. I have created single edit text object and used this object to add in multiple rows.


Lets assume that there are 5 rows so there are 5 edit texts. User can enter/delete numbers in any of the edittext. Depending on what user enters in respective edittexts, I want to update the label.The label should contain addition of all edittext values.


Thanks and regards.
















Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.










default






.

stackoverflow.comm

[android help] Transparent action bar in actionbarshearlock activity


enter image description here



without use actionbarshearlock:



just add this line: requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);


before setContentView(R.Layout.Test) in onCreate


and this line give you TRANSPARENT ActionBar



getActionBar().setBackgroundDrawable(
getResources().getDrawable(R.drawable.ab_bg_black));


like:



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

getActionBar().setBackgroundDrawable(
getResources().getDrawable(R.drawable.ab_bg_black));
}


for R.drawable.ab_bg_black just add drawable colour in string.xml like:



#80000000



same way using actionbarshearlock:




@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(SampleList.THEME); //Used for theme switching in samples
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
super.onCreate(savedInstanceState);
setContentView(R.layout.overlay);

//Load partially transparent black background
getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_bg_black));

}



Edited: *Start listview After Actionbar.*


enter image description here


if you are using actionbarshearlock then just do like below:



android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="?actionBarSize" >





.

stackoverflow.comm

[android help] How to get imagepath from thumbnail path of a image?


After a long time and relentless try, the solution is here


1. You need to find the image id which is image unique id from images table in thumbnail table, query to thumbnail provider(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI) if you do not understand it, refer here , specifically IMAGE_ID,


Step 1 is to get reterievedImageId.



reterievedImageId=Long.parseLong(cursor.getString(imageIdInImages));


2. Now using the reterievedImageId get the image path, by again quering the content provider, only this time query the Images media provider(MediaStore.Images.Media.EXTERNAL_CONTENT_URI)



String getImagePathFromThumbPath(String thumbPath)
{
String imagePath=null;
if(thumbPath!=null)
{
String[] columns_to_return ={MediaStore.Images.Thumbnails.IMAGE_ID};
String where =MediaStore.Images.Thumbnails.DATA+" LIKE ?";
long reterievedImageId=-1;
String valuesAre[]={"%"+thumbPath};
Cursor cursor = getContentResolver().query(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, columns_to_return, where, valuesAre, null);
if(cursor!=null)
{
int imageIdInImages=cursor.getColumnIndex(MediaStore.Images.Thumbnails.IMAGE_ID);

for (cursor.moveToFirst();!cursor.isAfterLast(); cursor.moveToNext())
{
//STEP 1 to retrieve image ID
reterievedImageId=Long.parseLong(cursor.getString(imageIdInImages));
}
if(reterievedImageId!=-1)
{
//STEP 2 Now
Log.i(TAG, "imageId-"+reterievedImageId);
String[] columnsReturn={MediaStore.Images.Media.DATA};
String whereimageId=MediaStore.Images.Media._ID+" LIKE ?";
String valuesIs[]={"%"+reterievedImageId};
Cursor mCursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columnsReturn, whereimageId, valuesIs, null);
int rawDataPath= mCursor.getColumnIndex(MediaStore.Images.Media.DATA);
for (mCursor.moveToFirst();!mCursor.isAfterLast(); mCursor.moveToNext())
{
imagePath=mCursor.getString(rawDataPath);
}
}
}
}
return imagePath;
}


If you still have doubt or error/exception, leave comment!



.

stackoverflow.comm

[android help] Failed to collect preference classes


I am very tired and very frustrated because of this problem. I am very new to writing android applications so by knowledge of eclipse is so basic it hurts. I want to know why when I start a new android project (using only default settings) I immediately get an these errors?


Error Fri Apr 12 00:08:30 EDT 2013 Android Framework Parser: failed to collect preference classes


Error Fri Apr 12 00:08:30 EDT 2013 Problem loading classes


Error Fri Apr 12 00:08:29 EDT 2013 Problem preloading classes


These errors occur immediately. I have not written anything or created any new files. I've been ignoring these errors for a while now being that they were not getting in the way of anything that I have been doing. Then when I tried to make a new preference file I ran into a brick wall. I have been looking up these errors for a week now and I haven't found one response that is dated this year, let alone given me any type of insight. What I did notice is that this web site came up with every one of my searches, so I decided to post it here.


If anyone can give me even a suggestion I would be very greatfull.



.

stackoverflow.comm

[android help] Cannot enable ActionbarSherlock


As per the instructions, I downloaded ABS 4.1, created a new project from existing sources in the library/ folder. As soon as I do that, a few errors pop up in the log:



[2012-10-02 10:47:30 - library] Unable to resolve target 'android-14'


Along with a huge number of errors:



[2012-10-02 10:34:40 - com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] Parser exception for C:\Users\****\Documents\Code\Eclipse\Ferric\AndroidManifest.xml: The markup in the document following the root element must be well-formed.


From what I can guess it is because I have not set the correct target SDK version. Hopw am I supposed to this in a library?



.

stackoverflow.comm

[android help] How to share video on youtube by droid share?


I'm create an app which is record video and share it.


For sharing i use Droid share functionality and it works.


In that email,facebook,skype,etc working perfect but when select youtube that not upload my video.


following code i used for share.



Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"SUBJECT_NAME");
sharingIntent.setType("video/*");
File newFile = new File(video_path);
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM,Uri.fromFile(newFile));
startActivity(Intent.createChooser(sharingIntent,"Where you want to share?"));


.

stackoverflow.comm

[android help] Hi how to load thumbnail from custom directory?

android - Hi how to load thumbnail from custom directory? - Stack Overflow




















hi i have searched a lot but i get samples to fetch thumbnail from an url or from http, but i actually need to get thumbnail of an image from my own directory on sdcard withot accesing the android's default thumbnail directory, thats is i need to fetch a thumbnail of an image from mnt/sdcard/myown/1.png can anybody help for this please?


Thanks in advance.
















Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.










default







.

stackoverflow.comm

[android help] Andriod XML Parsing using SAXParser


I have My Rss File Items :




Prasad
http://www.tele.com/rssHostDescr.php?hostId=15
http://www.tele.com/rssHostDescr.php?hostId=14
2013-04-10
Prasad



........................


etc.....................


I'm trying to parse the above file,I'm able to get all the information(title,link,date)but my requirement is to get url attribute value,How to get the URL value from media:thumbnail tag? Could any one help?


here my code:



public class HostsRssHandler extends DefaultHandler {
private List messages;
private HostsProfile currentMessage;
private StringBuilder builder;

public List getMessages(){
return messages;
}
@Override
public void characters(char[] ch, int start, int length)
throws SAXException {
super.characters(ch, start, length);
builder.append(ch, start, length);
}
@Override
public void endElement(String uri, String localName, String name)
throws SAXException {
super.endElement(uri, localName, name);
if (this.currentMessage != null){
if (localName.equalsIgnoreCase("tilte")){
currentMessage.setTitle(builder.toString());
} else if (localName.equalsIgnoreCase("link")){
currentMessage.setLink(builder.toString());
}
else if (localName.equalsIgnoreCase("media:thumbnail")){
currentMessage.setMediathumbnail(builder.toString());
}
else if (localName.equalsIgnoreCase("pubDate")){
currentMessage.setDate(builder.toString());
}


else if (localName.equalsIgnoreCase("item")){
messages.add(currentMessage);
}
builder.setLength(0);
}
}

@Override
public void startDocument() throws SAXException {
super.startDocument();
messages = new ArrayList();
builder = new StringBuilder();
}

@Override
public void startElement(String uri, String localName, String name,
Attributes attributes) throws SAXException {
super.startElement(uri, localName, name, attributes);
if (localName.equalsIgnoreCase("item")){
this.currentMessage = new HostsProfile();
}
}
}


Note:



else if (localName.equalsIgnoreCase("media:thumbnail")){
currentMessage.setMediathumbnail(builder.toString());// During My Program Execution, Here I'm not able to get any value
}


.

stackoverflow.comm

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...