Friday, April 12, 2013

[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...