Tuesday, April 23, 2013

[android help] Why can't I delete this contact in androidÉ


display_name is read-only.


Anyone who wants to do detailed work with the Contacts Provider should definitely read the Contacts Provider API guide and follow the Contacts Provider Android training. The Contacts provider is a complex database system with many rules, and you'll run into frustrating problems unless you understand the basic layout of the provider.


Both CommonDataKinds.StructuredName.DISPLAY_NAME and CommonDataKinds.Phone.NUMBER are set to data1, because in fact they don't refer to separate tables. Instead, they both refer to column DATA1 in ContactContracts.Data. All detailed data for contacts is stored in ContactContracts.Data, regardless of what it is. For example, all phone numbers and all email addresses for a contact are stored in ContactContracts.Data. The way you tell one type of row from another is through the row's MIMETYPE value. The documentation explains this in detail.


Another hint: you should avoid doing additions, deletions, or updates to the Contacts Provider in your own code. Instead, send an Intent that starts the device's contacts app or allows the user to choose the contacts app to use. This allows the user to do the work in the contacts app rather than your app. This is also described in the documentation.



.

stackoverflow.comm

[android help] Add Convert to JSONObject


I'm trying to figure out how to add the following data to my json object. Could someone show me how to do this.


{ "main_img":"Base64 String" }


However, the following is the result of using this code, to come out.



final int COMPRESSION_QUALITY = 100;
String encodedImage;
ByteArrayOutputStream byteArrayBitmapStream = new ByteArrayOutputStream();
bitmapPicture.compress(Bitmap.CompressFormat.JPEG, COMPRESSION_QUALITY,
byteArrayBitmapStream);
byte[] b = byteArrayBitmapStream.toByteArray();
encodedImage = "data:image/JPEG;base64," + Base64.encodeToString(b, Base64.DEFAULT);
return encodedImage;


{ "main_img":"Base64 String


It is displayed with }, " is missing.



.

stackoverflow.comm

[android help] Parse CDATA with XMLParser in this specific case for ANDROID


I've seen quite a few posts about this, but actually I did not get any to work. I am building a simple TV guide android application. I simply Use RSS from a tvprofil.net to show whats on TV today. The problem is, I do not know how to Parse CDATA in XML. I am using some standard parser with DOM... at least I think so..


This is a bit of XML:



.
.
.

RTS1 14.08.2012
Tue, 14 Aug 2012 06:00:00
06:05 Jutarnji program
08:00 Dnevnik

8:15 Jutarnji Program
09:00 Vesti ... ]]>


.
.
.


now, this is my main app:



public class Main extends ListActivity {

// All static variables
static final String URL = "http://tvprofil.net/rss/feed/channel-group-2.xml";
// XML node keys
static final String KEY_ITEM = "item"; // parent node
static final String KEY_NAME = "title";
static final String KEY_DATE = "pubDate";
static final String KEY_DESC = "content:encoded";

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


ArrayList> menuItems = new ArrayList>();



XMLParser parser = new XMLParser();
String xml = parser.getXmlFromUrl(URL); //get XML
Document doc = parser.getDomElement(xml); // get DOM elem.



NodeList nl = doc.getElementsByTagName(KEY_ITEM);
//loop
for (int i=0; i< nl.getLength(); i++){
HashMap map = new HashMap();
Element e = (Element) nl.item(i);
//add to map
map.put(KEY_NAME, parser.getValue(e, KEY_NAME));
map.put(KEY_DATE, parser.getValue(e, KEY_DATE));
map.put(KEY_DESC, parser.getValue(e, KEY_DESC));

// hash => list
menuItems.add(map);
}

ListAdapter adapter = new SimpleAdapter(this, menuItems, R.layout.list_item,
new String[]{KEY_NAME, KEY_DESC, KEY_DATE}, new int[]{
R.id.name, R.id.description, R.id.date
});
setListAdapter(adapter);

//singleView
ListView lv = getListView();

lv.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView parent, View view, int position, long id){
String name = ((TextView)view.findViewById(R.id.name)).getText().toString();
String date = ((TextView)view.findViewById(R.id.date)).getText().toString();
String description = ((TextView)view.findViewById(R.id.description)).getText().toString();

//intent
Intent in = new Intent(getApplicationContext(), SingleMenuItemActivity.class);
in.putExtra(KEY_NAME, name);
in.putExtra(KEY_DATE, date);
in.putExtra(KEY_DESC, description);
startActivity(in);
}
});

}

}


and the parser class:



public class XMLParser {

// constructor
public XMLParser() {

}

/**
* Getting XML from URL making HTTP request
* @param url string
* */
public String getXmlFromUrl(String url) {
String xml = null;


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

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

} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// return XML
return xml;
}

/**
* Getting XML DOM element
* @param XML string
* */

public Document getDomElement(String xml){

Document doc = null;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {

DocumentBuilder db = dbf.newDocumentBuilder();

InputSource is = new InputSource();
is.setCharacterStream(new StringReader(xml));
doc = db.parse(is);

} catch (ParserConfigurationException e) {
Log.e("Error: ", e.getMessage());
return null;
} catch (SAXException e) {
Log.e("Error: ", e.getMessage());
return null;
} catch (IOException e) {
Log.e("Error: ", e.getMessage());
return null;
}

return doc;
}

/** Getting node value
* @param elem element
*/
public final String getElementValue( Node elem ) {

Node child;
if( elem != null){
if (elem.hasChildNodes()){
for( child = elem.getFirstChild(); child != null; child = child.getNextSibling() ){
if( child.getNodeType() == Node.TEXT_NODE ){
return child.getNodeValue();
}
}
}
}
return "";
}

/**
* Getting node value
* @param Element node
* @param key string
* */
public String getValue(Element item, String str) {
NodeList n = item.getElementsByTagName(str);
return this.getElementValue(n.item(0));
}
}


there is one more class for Single menu item.. but I think it's irrelevant in this case. Now, I'd just like to see no HTML tags after parsing it and dealing with CDATA... Anyone got idea about this one?



.

stackoverflow.comm

[android help] File Paths between Air and native extension (Android)

File Paths between Air and native extension (Android) - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















I know how to build a native extension. I am building one to send a file attachment to an app chooser intent for email.I want to send a String containing the file.nativePath to the extension.


However my question is this:


Does Android read the nativePath String the same as AS3? In otherwords, Will Android be able to find the file from the path that I send it?
















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










default






.

stackoverflow.comm

[General] Three blank posts at the top of each page of each thread




Quote Originally Posted by B. Diddy View Post

I'm only seeing it on the mobile app. I'm guessing there's a little glitch in the server.



Yes. I neglected to mention that. I just assume everyone comes here from their phone/tablet.

Odd there are only two in this thread. Maybe it has to reach a certain number of posts for three or three is for existing threads and two for any new ones after the glitch started.

Sent from my totally awesome Sprint Galaxy Nexus, even if I don't know all its secrets yet.


.

forum.xda-developers.com

[General] Home Screens in Samsung Galaxy S3.


Hi,

Recently I bought a Samsung Galaxy S3 phone. I read in one of the forums that Galaxy S3 has 7 home screens. But, the phone i bought has only 6 home screens. Could any one help me How to add the 7th screen?

Regards,
Rama Krishna



.

forum.xda-developers.com

[General] Black screen


Hey Guys! I'm new to android and I would really much like to play Gangstar Rio! But the problem is.... no matter how much I want to play it... When I start it, the screen goes black! Please help me on this one.. Thx



.

forum.xda-developers.com

[General] The Android Central App.


Hi.
I was wondering, is the Android Central and Crackberry App sup post to act like this.
I know there are new apps coming, but I can't wait. I've heard that the app are going to be discontinued too.
The apps started acting strange today, both. The 1st 2nd and 3rd are cut out, off each page. Though not unusable, the 1st post is now the 4th, and the 2nd is the 5th it is quite annoying..

Example:
The Android Central App.-uploadfromtaptalk1366692943404.jpg

Any help?
Thanks.

Sent from my MZ604 using Android Central Forums



.

forum.xda-developers.com

[android help] Error message while opening a project in eclipse

android - Error message while opening a project in eclipse - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















I was trying to open a project by clicking on it(ie. expanding the project folder).I get this message


enter image description here


Any suggestions for this problem?


























U should try this: uninstall your eclipse and reinstall it. may be your eclipse is not supported by your hardware specifications




















default






.

stackoverflow.comm

[android help] Android : Process has died / AsyncTask HTTP get


The Low Memory: No more background processes is a dead giveaway in your case. The device ran out of memory. When it does, it stops processes. It stops them in following order:


  1. Processes without any activity or service, i.e. applications that were put on background and stay running in case the user will need them again.

  2. Processes with background services like checking email.

  3. Processes with foreground services like background download or playing music player.

  4. Processes with foreground activities, i.e. the application being used.

Apparently your application loads too many bitmaps and exhausts all memory. The system first stops everything that is not needed, but when you keep loading bitmaps, it has to kill things that are needed too. The background download service goes first, because it's in the third case above.


You simply have to make sure you never have many bitmaps in memory at the same time. Note, that flash memory is rather fast and using lot of memory slows the device down itself, so it's unlikely that keeping more than the bitmaps on display and a few most recently used ones in memory helps anything.



.

stackoverflow.comm

[android help] android - strings.xml vs static constants


There are both some advantages and disadvantages ( I should say advantages and less advantages) in these two cases.


as in the comments of your question they said it all. I just want to add some minor points.


Localization:


For localization issue definitely String resource is the best as you can use different language file for differente Locale.


Memory:


As String resources are saved in xml file so there are some extra overhead (not a major one though)


Performance:


reading from memory is always faster than reading from file. Although in this case the performance difference is not significant


Maintainance:


It is just a personal opinion. To me maintaining res file is easier than maintaining string in class. string.xml is more readable to me.


Finally:


So my suggestion is




use string resources for the texts which will be displayed to user.


and



use static constants for internal puposes of your program like database names, internal variable, intent filter name etc.




.

stackoverflow.comm

[General] Music Not Showing Up


Hi, I have numerous music albums/artists/songs loaded onto my SD card that are not showing up in my music player. I have tried installing several different music players with the same results. The same music files are not showing up. I've tried, as has been suggested online, unmounting my SD card, removing it, putting it back in, then "refreshing" my player or having the player re-scan the music collection, nothing helps so far. All the music files are .mp3's. Is there a certain way music files have to be titled, or something else that could be causing the problem? Is there a limit to the number of music files? I only have 1000 or so. I also tried clearing my Media Storage cache, no luck either. It's really a drag because my phone is my main source of music, especially when driving, and I just can't get to hear some of my favorite songs. Any suggestions for this problem? Thanks!



.

forum.xda-developers.com

[android help] FragmenManager replace makes overlay


I'm using supportlib v4 to reach master-detail flow.


Problem: New instance of "details" fragment overlays the first one (xml created) instead replace it.


My Activity layout is:



xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".TrackListActivity" >

android:id="@+id/fragmentList"
android:name="pl.com.digita.BikeComputerUi.TrackList.TrackListFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />

android:id="@+id/fragmentTrack"
android:name="pl.com.digita.BikeComputerUi.TrackList.TrackInfoFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2" />




Method called after click:



private void showDetails(long trackId){
View fragmentContainer = getActivity().findViewById(R.id.fragmentTrack);
TrackInfoFragment trackInfoFragment = TrackInfoFragment.newInstance(trackId);
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(fragmentContainer.getId(), trackInfoFragment).commit();

}


.

stackoverflow.comm

[General] How Can I Make My Samsung S3's Display the Same as PC?


Hello, everyone!

I've been having this problem for about a month now because I never really dealt much into the display on my phone and my computer until I was looking for a specific color.

I want to know if ever you guys know or can suggest a Display Settings so that the color/pictures on the S3 is almost exactly the same as the ones in my computer. It's sad that in my phone, the photos look so great but when I upload or share them on Facebook, it looks washed out and lacks color. Also, I Googled the color teal... It looks sooo different in the S3 because it has more contrast, however, when I took a screenshot of it and uploaded it on Facebook, it looks the same as the one that can be found in the PC.

See, it affects how I edit my photos. Looks great on phone, terrible on PC.

HELP!!!!!



.

forum.xda-developers.com

[android help] How to detect special characters in an edit text and display a Toast in response (Android)?


An apology for my bad English, I'm using google translate.


I'm creating an activity in which users must create a new profile. I put a limit to edit text of 15 characters and I want that if the new profile name has spaces or special characters display a warning. As online video games


The following code helps me to detect spaces, but not special characters.


I need help to identify special characters and display a warning in response.


@Override public void onClick(View v) {



//Convertimos el contenido en la caja de texto en un String
String nombre = nombreUsuario.getText().toString();


//Si el tamaño del String es igual a 0, que es es lo mismo que dijeramos "Si esta vacio"
if (nombre.length() == 0){

//Creamos el aviso
Toast aviso = Toast.makeText(getApplicationContext(), "Por favor introduce un nombre de Usuario", Toast.LENGTH_LONG);
aviso.show();

}else if (nombre.contains(" ")| nombre.contains("\\W")) {
Toast aviso = Toast.makeText(getApplicationContext(), "No son permitidos los espacios ni los caracteres especiales", Toast.LENGTH_LONG);
aviso.show();

}else{
nombre = nombreUsuario.getText().toString();
//Conectamos con la base de datos
//Creamos un bojeto y lo iniciamos con new
Plantilla entrada = new Plantilla(CrearUsuarioActivity.this);
entrada.abrir();
//creamos un metodo para escribir en la base de datos (crear entradas)
entrada.crearEntrada(nombre);
entrada.cerrar();


.

stackoverflow.comm

[android help] OpenCV for Android - training SVM with SURF descriptors

OpenCV for Android - training SVM with SURF descriptors - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















I need some help in training a SVM for an Android app. I have a set of images in different classes (12 classes) and got all descriptors from them. I managed to get the same amount of descriptors for each image. What I need is to train a SVM for my android application with those descriptors. I'm not sure if I should train it in the Android emulator or write a C++ program to train the SVM and then load it in my app (if I use the OpenCV's lib for windows to train the SVM and then save it, will the lib I'm using for Android recognize the saved SVM file?). I guess I shouldn't train the SVM with such big dataset in the emulator. I've already tested my descriptor's dataset on the SMO of Weka (http://www.cs.waikato.ac.nz/ml/weka/) and got good results, but I need to implement (or use the openCV's) SVM and save it trained for future classification. I would really appreciate some example. Thanks in advice for the help!
















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










default






.

stackoverflow.comm

[General] New To Android - What is a launcher?


Welcome to the light side.

A launcher is essentially a new home screen that replaces (in the case of Samsung phones) Touchwiz. Examples include Go Launcher, Nova, Apex, and ADW. I use Nova.

These launchers generally offer more flexibility and customization options than stock launchers, like more rows or columns of icons, more icons in the dock, etc.



.

forum.xda-developers.com

[android help] Highlight the textcolor in android html.fromHtml


I have to develop one android application.


I have to display the textview using html.fromHtml .


Here this is my content:



**Hottie Mallika Sherawat speaks about the men whom she’s over the moon about**


In these text ,have aligned on html file like below:


Mallika Sherawat 


I have to highlight the that color on Mallika Sherawat text only on my android textview also.


How can i do ???


I have wrote below code:



String fullcontent = in.getStringExtra("FullContent");
full_content = fullcontent.substring(1);

lblContent = (TextView) findViewById(R.id.title1);

lblContent.setText(Html.fromHtml(full_content),TextView.BufferType.SPANNABLE);


Here the html.fromHtml is supported b,p,italic text..But why it is not supported for highlight the particular text ??? pls how can i do ???



.

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