Thursday, April 25, 2013

[android help] How to replace new line characters with actual new lines in a string in android?

How to replace new line characters with actual new lines in a string in 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 need to display a string which contains a lot of new line '\n'.These needs to be replaced with actual newlines in that string. How can I do that in android?
































you should concatenate the newline operator like:



String str = "This is testing" + "\n" + "How are you?";


you said from database you could split like:



String[] separated = str.split("\n");
separated[0]; // this will contain "This is testing"
separated[1]; // this will contain "How are you?"


and then concatenate them

























What seems to be happening is the string you receive from your database contains not the new line character, but rather the characters \ and n. The simplest fix is use simply the String.replace function to replace the character sequence \ n by the character \n like so:



String str = getStringWithFakeNewlines();
str.replace("\\n", "\n"); // The first backslash is doubled to find actual backslashes



















default






.

stackoverflow.comm

[android help] Sax parser with string xml + malformation error


This will work as expected


Type.java



package com.example.test;

public class Type
{
private String lory;
private String car;

public String getLory()
{
return lory;
}

public void setLory(String lory)
{
this.lory = lory;
}

public String getCar()
{
return car;
}

public void setCar(String car)
{
this.car = car;
}

@Override
public String toString()
{
return "Lory : " + this.lory + "\nCar : " + this.car;
}

public String getDetails()
{
String result = "Lory : " + this.lory + "\nCar : " + this.car;
return result;
}
}


SAXXMLHandler.java



package com.example.test;

import java.util.ArrayList;
import java.util.List;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class SAXXMLHandler extends DefaultHandler
{
private List types;
private String tempVal;
private Type tempType;

public SAXXMLHandler()
{
types = new ArrayList();
}

public List getTypes()
{
return types;
}

// Event Handlers
@Override
public void startElement(String uri, String localName, String qualifiedName, Attributes attributes) throws SAXException
{
// reset
tempVal = "";
if ( qualifiedName.equalsIgnoreCase("data") )
{
// create a new instance of type
tempType = new Type();
}
}

@Override
public void characters(char[] ch, int start, int length) throws SAXException
{
tempVal = new String(ch, start, length);
}

@Override
public void endElement(String uri, String localName, String qualifiedName) throws SAXException
{
if ( qualifiedName.equalsIgnoreCase("type") )
{
// add it to the list and create new instance
types.add(tempType);
tempType = new Type();
}
else if ( qualifiedName.equalsIgnoreCase("lory") )
{
tempType.setLory(tempVal);
}
else if ( qualifiedName.equalsIgnoreCase("car") )
{
tempType.setCar(tempVal);
}
}
}


SAXXMLParser.java



package com.example.test;

import java.io.InputStream;
import java.util.List;

import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

import android.util.Log;

public class SAXXMLParser
{
public static List parse(InputStream is)
{
List types = null;
try
{
// create a XMLReader from SAXParser
XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
// create a SAXXMLHandler
SAXXMLHandler saxHandler = new SAXXMLHandler();
// store handler in XMLReader
xmlReader.setContentHandler(saxHandler);
// the process starts
xmlReader.parse(new InputSource(is));
// get the `Type list`
types = saxHandler.getTypes();
}
catch ( Exception ex )
{
Log.d("XML", "SAXXMLParser: parse() failed");
}
// return Type list
return types;
}
}


SAXParserActivity.java



package com.example.test;

import java.io.ByteArrayInputStream;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class SAXParserActivity extends Activity implements OnClickListener
{
Button button;
List types = null;

@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(this);
}

@Override
public void onClick(View v)
{
String xml = " vroom crack doom chack ";
types = SAXXMLParser.parse(new ByteArrayInputStream(xml.getBytes()));
Log.d("SSDDSD", "Length : " + "" + types.size());
for ( Type type : types )
{
Log.d("SAXParserActivity", type.toString());
Toast.makeText(getApplicationContext(), type.toString(), Toast.LENGTH_SHORT).show();
}
}
}


main.xml




android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dip" >
android:id="@+id/button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Parse XML Using SAX" />



You can see the output in both LogCat and Toast.



.

stackoverflow.comm

[android help] Source Not Found main.xml Eclipse


Im a beginner to android developing and have run into a problem. Im making a simple app that displays presidents in a List View. But when I try to run it on the emulator, ir gets this error: Source not Found net.learn2develop.Listfragmentexample.ListFragmentExampleActivity. Here is my code for the java file:



package net.learn2develop.Listfragmentexample;

import android.app.ListFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class Fragment1 extends ListFragment {
String[] presidents = {
"Dwight D. Eisenhower",
"John F. Kennedy",
"Lyndon B. Johnson",
"Richard Nixon",
"Gerald Ford",
"Jimmy Carter",
"Ronald Reagen",
"George H. W. Bush",
"Bill Clinton",
"George W. Bush",
"Barack Obama"
};

@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment1, container, false);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter(getActivity(),
android.R.layout.simple_list_item_1, presidents));
}
public void onListItemClick(ListView parent, View v,
int position, long id)
{
Toast.makeText(getActivity(),
"You have selected item : " + presidents[position],
Toast.LENGTH_SHORT).show();
}
}


Here is the code for the main.xml:



xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >

android:id="@+id/fragment1"
android:name="net.learn2develop.ListFragmentExample.Fragment1"
android:layout_weight="0.5"
android:layout_width="0dp"
android:layout_height="200dp" />

android:id="@+id/fragment2"
android:name="net.learn2develop.ListFragmentExample.Fragment1"
android:layout_weight="0.5"
android:layout_width="0dp"
android:layout_height="300dp" />




And here is the code for fragment1.xml:




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

android:id="@id/android:list"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawSelectorOnTop="false"/>



Here is my Logcat trace:



[2013-04-25 18:31:55 - ListFragmentExample] Android Launch!
[2013-04-25 18:31:55 - ListFragmentExample] adb is running normally.
[2013-04-25 18:31:55 - ListFragmentExample] Performing net.learn2develop.Listfragmentexample.ListFragmentExampleActivity activity launch
[2013-04-25 18:31:55 - ListFragmentExample] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'Android_4.0'
[2013-04-25 18:31:55 - ListFragmentExample] Uploading ListFragmentExample.apk onto device 'emulator-5554'
[2013-04-25 18:31:56 - ListFragmentExample] Installing ListFragmentExample.apk...
[2013-04-25 18:32:03 - ListFragmentExample] Success!
[2013-04-25 18:32:03 - ListFragmentExample] Starting activity net.learn2develop.Listfragmentexample.ListFragmentExampleActivity on device emulator-5554
[2013-04-25 18:32:05 - ListFragmentExample] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=net.learn2develop.Listfragmentexample/.ListFragmentExampleActivity }
[2013-04-25 18:32:06 - ListFragmentExample] Attempting to connect debugger to 'net.learn2develop.Listfragmentexample' on port 8666


Here is my Manifest code:




package="net.learn2develop.Listfragmentexample"
android:versionCode="1"
android:versionName="1.0" >

android:minSdkVersion="14"
android:targetSdkVersion="14" />

android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:name="net.learn2develop.Listfragmentexample.ListFragmentExampleActivity"
android:label="@string/app_name" >












Can someone fill me in here? I dont know what im doing wrong. Any help is much appreciated!



.

stackoverflow.comm

[android help] Execute a thread of an activity based on item position clicked in ListView


Okay, here is the the problem I am having. I am developing a simple messaging client similar to the OEM one found on Android devices.


I currently have a ConversationList.java containing a ListView with the usernames of people the actual user is engaged in conversation with.


I want to launch specific threads of a ConversationThread.java (which is an activity that contains another ListView holding the messages exchanged between users).


I thought originally about instantiating a new ConversationThread upon each addition of a conversation in ConversationList.java, then adding that to an array list. Then based on the position parameter on the onItemClick on the ListView referenced to the position of the ArrayList of ConversationThread execute that particular "thread" of ConversationThread.



public class ConversationList extends Activity
{
ArrayList ListOfActiveThreads = new ArrayList();
ListView convoList;
ArrayAdapter adapter;
ArrayList ActiveConversations = new ArrayList();

@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_conversation_list);
convoList = (ListView) findViewById( R.id.Conversations );
Button addConvo = (Button) findViewById(R.id.Talk);
adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, ActiveConversations);
convoList.setAdapter(adapter);

addConvo.setOnClickListener(new OnClickListener()
{
public void onClick(View v) //will add the person to be sending to to the list of active conversations
{
EditText person2add = (EditText) findViewById(R.id.Friend2Sendto);
String person = person2add.getText().toString();
ConversationThread newMessage = new ComversationThread(person);
ListOfActiveThreads.add(newMessage);
adapter.add(person);
adapter.notifyDataSetChanged();
person2add.setText("");

}
});

convoList.setOnItemClickListener(new ListView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView a, View v, int i, long l)
{

Intent mainIntent = new Intent(ConversationList.this, ConversationThread.class); //this starts a new instance of the ConversationThread class each time
startActivity(mainIntent);
/* Here I want to start or resume the ConversationThread.getposition(i) */
}
});

}


My question is, for the ConversationList.java I have a basic android activity template, with an oncreate() class etc. Do I make this class implement Runnable and somehow make it act like a Thread in Java? or is there a better way of creating a list of running activities to be utilized by the ListView.



.

stackoverflow.comm

[General] Delete contact from phone but NOT Gmail contacts


You could go to Settings/Accounts-Google/, tap your Google account, then uncheck Contacts. This will unsync your Contacts, so if you delete a contact on your phone, it won't delete from your main Google account. HOWEVER, if you check the Contacts box again, it will sync and then you will delete the contact from your Google account. So it's kind of a one-time deal.

Another option would be to import all of your Google Contacts into your Phone account, not your Google account, using the Import function in the People app. Then you could unsync Google Contacts to remove all of the contacts that sync with your Google Account. You would then have all of your Google Contacts in your Phone account, which does NOT sync with your Google account, and so if you delete an contact on your phone, it won't delete in your Google Account.

Sorry, that sounded pretty confusing, didn't it?



.

forum.xda-developers.com

[General] 3 problems with a kyocera hydro phone


1 When I go to system settings > sound > phone ringtone (right now it is set to unknown ringtone) the "unknown ringtone" sounds like the gong from "the gong show" (for you young people the gong in question is an old Chinese gong). When I try to change the phones default ringtone. It will take and last maybe a few days to maybe a week then revert back to the Chinese gong ringtone (with the name unknown ringtone). The phone is rooted and I have checked every sound file and ringtone I could find (I only looked in the logical places were the ringtones would be stored). I even found the sound files for things like the keyboard click, the camera shutter click and so on. I played every sound file that I could find and no gong. That gong ringtone has to be in the phone somewere. I am a tech though I am better at Windows based stuff then Android/Linux Os, But I am learning. It took me about 2 months of reading everything I could find online about rooting before I even tried to root the phone. I also fix 2 way radios, a little background on me. I have never had a cell phone change ringtones on it's own like this and I am stumped.

2. This started a few days ago. The icon for the voice mail is up in the pull down menu on the very top of the phone even though there is no voice mail messages. I can't get the icon to go away. I have already tried pulling the battery for a few hours and no change.

3. This started last night. I have no internet available on the phone unless I turn on the wifi and tie into my wireless router. The voice and sms still work fine.

Anyone have any ideas short of chucking the phone and getting a new one?

Steve



.

forum.xda-developers.com

[General] Samsung Note II VZW - No data from WiFi or cell signal


As the title says, I'm getting no data from my home WiFi or 4G from the cell signal, despite them being shown as connected.
I noticed it just a few minutes ago. I was looking into Voodoo RootKeeper because I haven't updated to the latest OTA update and I've been wanting to soon, it was mentioned that SuperUser should be fully updated for it to work. While looking through SU settings, I noticed the option to set SU as a system app, so I did it. It rebooted and just before finishing the boot it had a message saying something about configuring apps (similar to what you would see after an update, I believe). Once it finished I was going to update some apps that needed updating and Play said it had no connection, checked Chrome and it was the same story. So here I am.

My Note II is on Verizon, it is rooted, also has an unlocked bootloader (which is why I've waited so long to do the OTA). I haven't updated since I got it at the beginning of December last year, so the current version I'm running is 4.1.1

Any help is really extremely appreciated; my smartphone becomes a dumb phone without any networking, dumb phones make me sad



.

forum.xda-developers.com

[General] Go SMS Pro, how to delete a picture


My wife sent me a picture in a text using Go SMS Pro, when i received the text it had a link that took me to the picture via the internet. It had a simple download button to download it to my phone with nothing else on the screen. My question is where are these pictures being stored at, and can you get them deleted.



.

forum.xda-developers.com

[android help] Test data sources in Android unit testing


I want to test parsing of data returned from server.


I thought I might create several test XML files and then feed them to the sax parser which uses my custom data handler (as in the application that I test).


But where should I put those test XMLs?


I tried with [project_root]/res/xml, but then I get the error:


android.content.res.Resources$NotFoundException: Resource ID #0x7f040000 type #0x1c is not valid at android.content.res.Resources.loadXmlResourceParser(Resources.java:1870) at android.content.res.Resources.getXml(Resources.java:779)


Does that mean that the xml is invalid, or that android couldn't find the XML file? (I use the same XML that comes from the server - copied it from the firebug's net panel and pasted into the file).


Can I somehow read that XML as a text file, since getContext().getResources().getXml(R.xml.test_response1) returns XmlResourceParser instead of String (which I'd prefer)?



.

stackoverflow.comm

[General] Suddenly unable to connect my N7 to my phone with bluetooth


Tried that. Still didn't work. Also tested with my blue tooth headphones, those connected up just fine. Also unpaired and tried from step 1, and still no go.

Also, if it helps. I noticed that they actually don't even bother connecting to each other. Say for example, my headphones. I tap on the headphone's name on the list and it goes "connecting..." Even if the headphones are off. When I try to get my S3 and N7 to connect, they don't even get to that point.



.

forum.xda-developers.com

[android help] possible to change text size/color for ActionBar?


Is there possible way to change size/color of ActionBar's title and subtitle?


I am using ActionBarSherlock for bridging between lower and higher versions. ActionBarSherlock provides way to customize text style in SherlockActionBarCompat, but there seems no way to make it in SherlockActionBarNative.


edit: added by Jake and removed by author


edit: Close to the solution:










Thank Jake, the author of ABS, for the help.


Now it's almost done, except that the actionBarSize can only be estimated for an approximate absolute dimension(60dp for my app) from quite a few trials; wrap_content causes API2.2 to expand the whole screen and does API4.2.2 exception thrown while parsing xml.


Addition:
when actionBarSize set as 0dp, the output is as (http://i.stack.imgur.com/xX4E1.png , low reputation to post images): API2.2 in the left, the action bar occupies the whole screen without title, API4.2.2 in the right, content does without action bar.


when set as wrap_content, same output for API2.2, and exception thrown as: Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x10



.

stackoverflow.comm

[android help] Android: Connect to a Server when offline

Android: Connect to a Server when offline - 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.

















Hi I'm working on an Android App which has the possibility of connecting to a server. This application can work online or offline. For connection to the server, I use AsyncTask, which and in doInBackground is where I do all the network operations. Then I create a new instance of the Asynctask when I click a button. What I would like to know is if there is a way of checking if the server is active in order to launch the AsyncTask. I have thought of try and catch but I would like to know if there is a better solution
















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










default







.

stackoverflow.comm

[android help] Inner join order by performance issue in Android 2.3


I have used sql select query in android app which works fine on newer versions of android i.e it takes 30 to 40 seconds on Samsung galaxy tab( android 4.0.3) to retreive data from sqlite database, but on device with older version of android 2.3 it takes 18 minutes to retreive data. If i remove "order by x_unitperson.UNITSEQ" then its performance do not decreases on android 2.3. How can i increase its performance on android 2.3 without removing order by clause.


My sql is:



SELECT PERSON_ID,
COMMANDER,
CITIZEN,
RANK,
GIVEN,
SURNAME,
ISOR,

(SELECT GROUP_CONCAT(NAME_SHORT, '\n')
FROM units
INNER JOIN
(SELECT *
FROM x_unitperson
WHERE PERSON_ID = people.PERSON_ID
ORDER BY x_unitperson.UNITSEQ) AS xunits
WHERE units.UNIT_ID = xunits.UNIT_ID) AS NAME_SHORT,

(SELECT FNAME
FROM photos
WHERE PERSON_ID = People.PERSON_ID) AS FNAME
FROM people
ORDER BY SURNAME,
GIVEN


.

stackoverflow.comm

[General] HELP i think I messed up my phone


OK, so i tried to take the root off my Rugby Pro SGH- I547 and used a recovery from the site here with Odin3_v3.04. I put the comanche_stock_boot_recovery_system.tar on and it took my Bell phone to AT&T now at the start up. Now my wi-fi doesn't work and a lot of other things. What do i do to get this back to the way it was with bell. I tried factory reset and still have AT&T. Help plz.



.

forum.xda-developers.com

[android help] Converting YUV->RGB(Image processing)->YUV during onPreviewFrame in android?


I am capturing image using SurfaceView and getting Yuv Raw preview data in public void onPreviewFrame4(byte[] data, Camera camera)


I have to perform some image preprocessing in onPreviewFrame so i need to convert Yuv preview data to RGB data than image preprocessing and back to Yuv data.


I have used both function for encoding and decoding Yuv data to RGB as following :



public void onPreviewFrame(byte[] data, Camera camera) {
Point cameraResolution = configManager.getCameraResolution();
if (data != null) {
Log.i("DEBUG", "data Not Null");

// Preprocessing
Log.i("DEBUG", "Try For Image Processing");
Camera.Parameters mParameters = camera.getParameters();
Size mSize = mParameters.getPreviewSize();
int mWidth = mSize.width;
int mHeight = mSize.height;
int[] mIntArray = new int[mWidth * mHeight];

// Decode Yuv data to integer array
decodeYUV420SP(mIntArray, data, mWidth, mHeight);

// Converting int mIntArray to Bitmap and
// than image preprocessing
// and back to mIntArray.

// Encode intArray to Yuv data
encodeYUV420SP(data, mIntArray, mWidth, mHeight);
}
}

static public void decodeYUV420SP(int[] rgba, byte[] yuv420sp, int width,
int height) {
final int frameSize = width * height;

for (int j = 0, yp = 0; j < height; j++) {
int uvp = frameSize + (j >> 1) * width, u = 0, v = 0;
for (int i = 0; i < width; i++, yp++) {
int y = (0xff & ((int) yuv420sp[yp])) - 16;
if (y < 0)
y = 0;
if ((i & 1) == 0) {
v = (0xff & yuv420sp[uvp++]) - 128;
u = (0xff & yuv420sp[uvp++]) - 128;
}

int y1192 = 1192 * y;
int r = (y1192 + 1634 * v);
int g = (y1192 - 833 * v - 400 * u);
int b = (y1192 + 2066 * u);

if (r < 0)
r = 0;
else if (r > 262143)
r = 262143;
if (g < 0)
g = 0;
else if (g > 262143)
g = 262143;
if (b < 0)
b = 0;
else if (b > 262143)
b = 262143;

// rgb[yp] = 0xff000000 | ((r << 6) & 0xff0000) | ((g >> 2) &
// 0xff00) | ((b >> 10) & 0xff);
// rgba, divide 2^10 ( >> 10)
rgba[yp] = ((r << 14) & 0xff000000) | ((g << 6) & 0xff0000)
| ((b >> 2) | 0xff00);
}
}
}


static public void encodeYUV420SP_original(byte[] yuv420sp, int[] rgba,
int width, int height) {
final int frameSize = width * height;

int[] U, V;
U = new int[frameSize];
V = new int[frameSize];

final int uvwidth = width / 2;

int r, g, b, y, u, v;
for (int j = 0; j < height; j++) {
int index = width * j;
for (int i = 0; i < width; i++) {
r = (rgba[index] & 0xff000000) >> 24;
g = (rgba[index] & 0xff0000) >> 16;
b = (rgba[index] & 0xff00) >> 8;

// rgb to yuv
y = (66 * r + 129 * g + 25 * b + 128) >> 8 + 16;
u = (-38 * r - 74 * g + 112 * b + 128) >> 8 + 128;
v = (112 * r - 94 * g - 18 * b + 128) >> 8 + 128;

// clip y
yuv420sp[index++] = (byte) ((y < 0) ? 0 : ((y > 255) ? 255 : y));
U[index] = u;
V[index++] = v;
}
}


The problem is that encoding and decoding Yuv data might have some mistake because if i skip the preprocessing step than also encoded Yuv data are differ from original data of PreviewCallback.


Please help me to resolve this issue. I have to used this code in OCR scanning so i need to implement this type of logic.


If any other way of doing same thing than please provide me.


Thanks in advance. :)



.

stackoverflow.comm

[android help] Memory overflow when loading large textures


I have a GLSurfaceView and a Renderer which loads textures in onSurfaceCreated. My textures are created like so :



public Texture3D(final GL10 gl, final int id) {
_pBitmap = BitmapFactory.decodeResource(Utils.getResources(), id);
gl.glEnable(GL10.GL_TEXTURE_2D);

gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
texture = newTextureID(gl);
gl.glBindTexture(GL10.GL_TEXTURE_2D, texture);
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);

gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);


GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, _pBitmap, 0);

_pBitmap.recycle();
_pBitmap = null;

gl.glEnable(GL10.GL_BLEND);
}


I store them in an HashMap :



textures.put(R.drawable.tile, new Texture3D(gl, R.drawable.tile));


My problem is when I create a texture from a large image (720x1280, 561 Ko) after I sometimes get the following error :



04-24 11:05:19.870: D/dalvikvm(27953): GC_CONCURRENT freed 26K, 18% free 50397K/60743K, paused 18ms+6ms, total 57ms
04-24 11:05:19.870: D/dalvikvm(27953): WAIT_FOR_CONCURRENT_GC blocked 2ms
04-24 11:05:19.895: D/dalvikvm(27953): GC_FOR_ALLOC freed 7K, 18% free 50390K/60743K, paused 25ms, total 25ms
04-24 11:05:19.900: I/dalvikvm-heap(27953): Forcing collection of SoftReferences for 14745616-byte allocation
04-24 11:05:19.940: D/dalvikvm(27953): GC_BEFORE_OOM freed 10K, 18% free 50380K/60743K, paused 41ms, total 41ms
04-24 11:05:19.940: E/dalvikvm-heap(27953): Out of memory on a 14745616-byte allocation.
04-24 11:05:19.940: I/dalvikvm(27953): "GLThread 11210" prio=5 tid=35 RUNNABLE
04-24 11:05:19.940: I/dalvikvm(27953): | group="main" sCount=0 dsCount=0 obj=0x42ec2008 self=0x6095d078
04-24 11:05:19.940: I/dalvikvm(27953): | sysTid=29199 nice=0 sched=0/0 cgrp=apps handle=1623155456
04-24 11:05:19.940: I/dalvikvm(27953): | schedstat=( 142147207 17456123 110 ) utm=11 stm=2 core=2
04-24 11:05:19.940: I/dalvikvm(27953): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
04-24 11:05:19.945: I/dalvikvm(27953): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:623)
04-24 11:05:19.945: I/dalvikvm(27953): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:476)
04-24 11:05:19.945: I/dalvikvm(27953): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:499)
04-24 11:05:19.945: I/dalvikvm(27953): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:529)
04-24 11:05:19.945: I/dalvikvm(27953): at com.gbanga.opengl.Texture3D.(Texture3D.java:73)
04-24 11:05:19.945: I/dalvikvm(27953): at com.gbanga.opengl.Texture3D.setupTextures(Texture3D.java:169)
04-24 11:05:19.945: I/dalvikvm(27953): at com.gbanga.opengl.OpenGLRenderer.onSurfaceCreated(OpenGLRenderer.java:440)
04-24 11:05:19.950: I/dalvikvm(27953): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1494)
04-24 11:05:19.950: I/dalvikvm(27953): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)


That points to the first line of the constructor where I use BitmapFactory.decodeResource. On my Galaxy S3 I get the error when I switch to another fragment and then I come back to the fragment that displays the GLSurfaceView (onPause and onResume are called on the GLSurfaceView).


How can I avoid this problem ? I tried this solution but I lose too much quality and in rare case the bug happens anyway (probably on old phones models).


Is there something wrong how I create / store my textures ? Also do you know why I don't always get this error ? (generally I get it the second time I load the textures).



.

stackoverflow.comm

[General] Ting Discount or Ting offers code is Now Available


My friend tells me Ting now offers promotion code for new accounts.I will share the promo URLs on all members.
The Ting website will show you "you get a $25 credit to help you get started with Ting" if you sign up or your friends sign up.
Here is the two Ting promo URLS,
OR
The above URLS are the same.
Terms and Conditions
1.Ting promo code/URL is reusable and can be distributed to as many people as you like.
2.This offer is only valid for first device purchase on new accounts.
Description of Ting:
Ting is mobile phone service that makes sense: no contracts, great rates, and no-hold customer support.
Hope i can help you!



.

forum.xda-developers.com

[android help] In-App payment in amazon

android - In-App payment in amazon - 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 have followed the following steps As shown in image ..steps in In AppPayment amazon but the problem is when i run the code provided in sdk as shown in image 4 when i click the button the number of clicks should be deducted but it is not. I have place the follwing values in string.xml m i right in theses steps?



amazoncheckout

com.amazon.checkout
com.amazoncheckoutconsumable
com.amazoncheckoutentitlementn
com.amazon.buttonclicker.blue_button
com.amazoncheckoutsubscription
com.amazoncheckoutsubscriptionmonthly


enter image description here


The above sku is generated by me and i also want to know the the json file shown in image three , i have downloaded that and placed in assert folder .. what is this json file for ? kind provide comment on my steps where i m wrong ... the click number is shown 5 but when i click it is not deducted why? any help will be appricated .... Thanks


















This question has an open bounty worth +50 reputation from Venkat ending in 6 days.


Looking for an answer drawing from credible and/or official sources.


i am stuck with this. please anybody help. i want to test the amazon app in my app.
















I'm going to try to explain how can you have the demo working, because, I think, that's your question, sorry if I'm wrong...



  1. Install the AmazonSDKTester.apk in your device and open it. It's inside tools folder in the SDK package. For install it you can use in terminal:


    adb install AmazonSDKTester.apk




  2. Next add your project to Eclipse:


    File > New > Project...>Android Project from Existing Code , browse the Button Clicker Demo Project in the SDK folder and Finish.




  3. Copy the amazon.sdktester.json file to SD memory. In the ButtonClicker project folder, go to assets folder and add the amazon.sdktester.json file to the SD memory. An easy way it's dragging the file to the SD folder using DDMS file explorer. Your SD folder may be different depends on device, in my Nexus S is like you can see in the image.



enter image description here


And that's it, you must have Button Clicker Demo sample fully working. When you make a purchase you can go to the AmazonSDKTester and see all your purchases. Hope it helps you and solves your problem.














Not the answer you're looking for? Browse other questions tagged or ask your own question.







default







.

stackoverflow.comm

[android help] reuse header ui design and functionality in all activities


I am working on application which have same header in all activites,in which there are some views in image views, buttons, textviews etc.


Now the The question is i want to use these header views in all the activites,but i do not want to re-code and re-design it in every activity.so is it possible to create a fragment of header views and reuse its ui and functionalities in all other activites.


  • if no,then any idea to make it reusable header?

  • if yes,then how ?

thanks for the help.!


updates in this question according to my research! i have researched and fond that it can easily acheived by using fragments.but i am still not getting that how? how can i acheive that functionality? according to this: reusable UI in android app


and this:


reusable ui with fragments


any links and code would be helpful!



.

stackoverflow.comm

[android help] how to stream videos from android device to PC


Plz can someone tell me how to stream videos from android device to PC ?



i was thinking about using the ftp protocol to share media stored on the phone but i don't know if that's easy to do ?




.

stackoverflow.comm

[android help] How to fit the images in webview from url


Now i am working on a list view with webview.in this listview webview is using for showing images.and it is from the url.now i am facing a problem that from url i am not getting the unique dimension images,some images are small and some are large,while showing this tho webview it not properly arranged.how can i properly arrange/fit the webview images.i am using the following code.



android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:id="@+id/webView"
android:layout_width="55dp"
android:layout_height="55dp"

>



WebView webView = (WebView)view.findViewById(R.id.webView);
showImageOnWebView(webView, item.thumbimage,80,80);


.

stackoverflow.comm

[android help] My Runner using a Handler is not working on android


Here's what I got so far guys, this is my app, all it does is display a digital clock and move the clock to a new part of the screen every 30 seconds, but it doesn't actually do that last part, here's the code:



public class MainActivity extends Activity {

private Runnable runnable = new Runnable(){
@Override
public void run() {
handler.sendEmptyMessage(0);
}
};
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
//change the text position here
this.postDelayed(runnable , 30000);
}
};

@Override
protected void onCreate(Bundle savedInstanceState) {


super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


TextView textView = (TextView) findViewById(R.id.digitalClock);
Random r = new Random();

Thread thread =new Thread(runnable );
thread.start();

int x = r.nextInt(350 - 100);
int y = r.nextInt(800 - 100);

textView.setX(x);
textView.setY(y);
}


I just cant seem to get this to work, been scanning the internet for about a week now. I think it's got something to do with the "New Thread" but not too sure what.



.

stackoverflow.comm

[General] Soundcloud link opens in google play


In facebook app, a friend posted a soundcloud file, when I click it, it takes me to soundcloud in the play store app. I installed it and still opens the play app. Facebook says it has no defaults set. I reset play's defaults and its still doing it.

Anyone?

Sent from my phone with the app.



.

forum.xda-developers.com

[android help] Playing mp4 video file in Android

media - Playing mp4 video file in 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 am trying to play a mp4 video file from remote url in android media player.but I am getting an error code --


Command PLAYER_PREPARE completed with an error or info PVMFErrNoResources error (1, -15)


I have searched for the error code and found that this error is returned if the resource required in processing of a request is not being available. A typical example is, a socket node connection not available for streaming.


link text


any help would be appreciated...





























i solved the problem by getting resumable video from Internet




















default







.

stackoverflow.comm

[android help] Android push Notification with Google Play

Android push Notification with Google Play - 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.

















In my project I want to give a push notification to the user if there is an update new version on Play store. I have to notify every time the user turn on phone. Is there any way to do this? Please help me on this


Thanks in Advance..
















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










default






.

stackoverflow.comm

[General] Lg nitro wifi problem


my phone connects to the wifi perfectly fine but when i lock the screen it disconnects, is there a way that it can stay on while its locked so that i can continue to use messaging apps when my phone is locked? HELPPP



.

forum.xda-developers.com

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