Thursday, May 9, 2013

[General] Rooted Nook Simple Touch/Android v.2.1 and Third-Party .apk File Permissions


Hi, Everyone...

I am a person of very little experience w/ mobile devices but have recently rooted (w/ serious help from a how-to) a Barnes & Noble Nook Simple Touch e-reader and enabled Android v. 2.1. It is a much more versatile system now w/ several apps allowing me to do much more than the stock device.

However. I cannot use any apps from GooglePlay (the site will not allow my device to access the apps because it does not meet the audio and video requirements), which severely limits the reader's flexibility. I have been able to make use of several excellent programs from the Amazon App Store, but it seems that I can only install those apps which are not third party .apk files. Consequently, my Amazon Kindle app is a very early version, limited in functionality but proprietary, while there are many later, third party versions available elsewhere on the Web.

My device has a couple of .apk app installers installed, but they will not even recognize the presence of a third party .apk on the SD card or on the main memory of the reader. I have the well-regarded "Root Explorer" app installed and, while it will locate the target third-party .apk file, the install command only results in the same error that there is an inability to parse the program. Further, I have read that Android devices usually have a menu system w/ access to system settings allowing a check to the option "allow third party sources", but my device has no such menu system, and I have not been able to install any app that would install such a menu (due to the same problem about third party sourced app files).

I have done quite a lot of searching as how to solve this problem but have given up--this is a bit frustrating because I feel that my experience must be encountered by many others having run up against the roadblock presented by the GooglePlay site.

I wonder, is there any way to access GooglePlay so that I might install many apps conforming to Android v.2.1? Is there any way to allow permission to third party sources that does not require a menu that my device does not have? Does anybody know of a reliable source for a Kindle Reader app that is not third-party sourced? (interestingly, the two primitive Kindle apps that are recognized by my device also show the Kindle logo on the app file; the other, later Kindle app versions have the Android logo.)

I would appreciate, so much, any help w/ this, and, as I say, I imagine that my problem is the experience many others, as well.

Thank you very much to all those who have read and/or reply to this post.

Regards, C.



.

forum.xda-developers.com

[General] Gmail account / picture download


Hello,

I have received emails with pictures in the email that I want to download to my phone. I am not anywhere near wi-fi to download the picture.When I try to download the pictures they will just sit there and then time out. Please let me know if there is a setting issue.

Thanks
Dan



.

forum.xda-developers.com

[General] [NOOB FRIENDLY] How to: iTunes music to any galaxy S phone


This works on Galaxy S, S2, S3, And S4. Lets get started!

1. Get this program called kies and install it and open it. Link:

2. Using the charger USB, Plug it into your computer, And of course, Plug in your Galaxy the other end.

3. Click music on kies, On the right.

4. Open iTunes, select your music

5. Drag it into kies on the music tab! And that's it! Hope this helped!



.

forum.xda-developers.com

[General] How do I add words to the dictionary on my Galaxy s4?


I got the Galaxy s4 yesterday. I'm going crazy just trying to add word to the dictionary. I can't even get it to spell my own name. It does not have the "personal dictionary" option under "language and input" that I am used to. I took it to Best Buy and three separate techs there played with it and they could not figure it out either.

How do I add words?



.

forum.xda-developers.com

[General] double sms tone


hi. i am using chomp sms and have created a custom notification tone. the problem is my phone makes 2 sounds every time i receive a text, the default sound followed by my tone. i read to disable the sms sound in the stock message app and i did that but it still makes the double sound. any one know how to fix this?
thanks

Edit: forgot to mention im using 4.2.2 jellybean on the galaxy s4 sprint



.

forum.xda-developers.com

[General] Trouble hearing phone calls but everyone says they hear me fine


I've notice lately, after flashing a custom rom, that during calls I can barely hear people on the other end yet they hear me fine. I have check all volume levels on my phone. Even with the call volume Zahl the way up and on speaker is still very hard to hear. It's extremely annoying and I have yet to find a post about it on this forum.

I did however find a post on another for with a similar problem and the way he went about fixing it was flashing a custom radio. I have no idea what that is and I can't find a thing about it on Google.
I need help with this situation badly because I don't know where else to look for answers. I have the galaxy note 2 by at&t rooted.

Sent from my SAMSUNG-SGH-I317 using Tapatalk 2



.

forum.xda-developers.com

[android help] upload image(blob) to specific container in azure


I did a camera application and i want to upload the picture taken by the camera into the blob storage in azure. Below is the code for me to select image from gallery and upload through the SAS URL. However when i tried entering the report class file, it force closes.



package com.example.testproject;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.net.HttpURLConnection;
import java.net.URL;

import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;



public class Report extends ListActivity {
private StorageService mStorageService;
private final String TAG = "BlobsActivity";
private String mContainerName;
private ImageView mImgBlobImage;
private Uri mImageUri;
private AlertDialog mAlertDialog;

Button btnSelect, btnR;
ImageView iv;
TextView tv1;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Get access to the storage service
StorageApplication myApp = (StorageApplication) getApplication();
mStorageService = myApp.getStorageService();
//Get data from the intent that launched this activity
Intent launchIntent = getIntent();
mContainerName = launchIntent.getStringExtra("ContainerName");

//Get the blobs for the selected container
mStorageService.getBlobsForContainer(mContainerName);


setContentView(R.layout.camera);
tv1=(TextView) findViewById(R.id.editText1);
btnR = (Button)findViewById(R.id.btnReport);
iv = (ImageView) findViewById(R.id.imageView1);
btnSelect = (Button)findViewById(R.id.btnSelect);
//Set select image handler
btnSelect.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
selectImage();
}
});

}

public void onClick(View v) {
mStorageService.getSasForNewBlob(mContainerName, tv1.getText().toString());

}

// Fire off intent to select image from gallery
protected void selectImage() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent, 1111);
}

// Result handler for any intents started with startActivityForResult
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
try {
//handle result from gallary select
if (requestCode == 1111) {
Uri currImageURI = data.getData();
mImageUri = currImageURI;
//Set the image view's image by using imageUri
mImgBlobImage.setImageURI(currImageURI);
}
} catch (Exception ex) {
Log.e(TAG, ex.getMessage());
}
}

/***
* Handles uploading an image to a specified url
*/
class ImageUploaderTask extends AsyncTask {
private String mUrl;
public ImageUploaderTask(String url) {
mUrl = url;
}

@Override
protected Boolean doInBackground(Void... params) {
try {
//Get the image data
Cursor cursor = getContentResolver().query(mImageUri, null,null, null, null);
cursor.moveToFirst();
int index = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
String absoluteFilePath = cursor.getString(index);
FileInputStream fis = new FileInputStream(absoluteFilePath);
int bytesRead = 0;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] b = new byte[1024];
while ((bytesRead = fis.read(b)) != -1) {
bos.write(b, 0, bytesRead);
}
byte[] bytes = bos.toByteArray();
// Post our image data (byte array) to the server
URL url = new URL(mUrl.replace("\"", ""));
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("PUT");
urlConnection.addRequestProperty("Content-Type", "image/jpeg");
urlConnection.setRequestProperty("Content-Length", ""+ bytes.length);
// Write image data to server
DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream());
wr.write(bytes);
wr.flush();
wr.close();
int response = urlConnection.getResponseCode();
//If we successfully uploaded, return true
if (response == 201
&& urlConnection.getResponseMessage().equals("Created")) {
return true;
}
} catch (Exception ex) {
Log.e(TAG, ex.getMessage());
}
return false;
}

@Override
protected void onPostExecute(Boolean uploaded) {
if (uploaded) {
mAlertDialog.cancel();
mStorageService.getBlobsForContainer(mContainerName);
}
}
}
}


Here is my logcat error



05-09 02:39:16.576: E/AndroidRuntime(1440): FATAL EXCEPTION: main
05-09 02:39:16.576: E/AndroidRuntime(1440): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testproject/com.example.testproject.Report}: java.lang.ClassCastException: android.app.Application cannot be cast to com.example.testproject.StorageApplication
05-09 02:39:16.576: E/AndroidRuntime(1440): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
05-09 02:39:16.576: E/AndroidRuntime(1440): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
05-09 02:39:16.576: E/AndroidRuntime(1440): at android.app.ActivityThread.access$600(ActivityThread.java:130)
05-09 02:39:16.576: E/AndroidRuntime(1440): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
05-09 02:39:16.576: E/AndroidRuntime(1440): at android.os.Handler.dispatchMessage(Handler.java:99)
05-09 02:39:16.576: E/AndroidRuntime(1440): at android.os.Looper.loop(Looper.java:137)
05-09 02:39:16.576: E/AndroidRuntime(1440): at android.app.ActivityThread.main(ActivityThread.java:4745)
05-09 02:39:16.576: E/AndroidRuntime(1440): at java.lang.reflect.Method.invokeNative(Native Method)
05-09 02:39:16.576: E/AndroidRuntime(1440): at java.lang.reflect.Method.invoke(Method.java:511)
05-09 02:39:16.576: E/AndroidRuntime(1440): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
05-09 02:39:16.576: E/AndroidRuntime(1440): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-09 02:39:16.576: E/AndroidRuntime(1440): at dalvik.system.NativeStart.main(Native Method)
05-09 02:39:16.576: E/AndroidRuntime(1440): Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to com.example.testproject.StorageApplication
05-09 02:39:16.576: E/AndroidRuntime(1440): at com.example.testproject.Report.onCreate(Report.java:42)
05-09 02:39:16.576: E/AndroidRuntime(1440): at android.app.Activity.performCreate(Activity.java:5008)
05-09 02:39:16.576: E/AndroidRuntime(1440): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
05-09 02:39:16.576: E/AndroidRuntime(1440): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
05-09 02:39:16.576: E/AndroidRuntime(1440): ... 11 more


Here is my StorageApplication Class



package com.example.testproject;

import android.app.Application;


public class StorageApplication extends Application {

private StorageService mStorageService;

public StorageApplication() {}

public StorageService getStorageService() {
if (mStorageService == null) {
mStorageService = new StorageService(this);
}
return mStorageService;
}

}


.

stackoverflow.comm

[android help] android image size from web


For starters, you are going to want to set a scaleType (try "center_inside") in your xml definition of the ImageView.


If you provide some code (in particular your layout xml file) I might be able to be of more assistance.


Update


Now, this may not fully be your problem, but it is a piece of it. DP (or DPI, they are the same thing) adjust for the screen density (pixels per inch), not the screen size. That means that an image of 200dp x 200dp will be approximately the same size in inches on both screens, not the same percentage of the screen.


Specs: Atrix 960 × 540 (https://en.wikipedia.org/wiki/Motorola_Atrix_2#Features) Galaxy Ace 480 x 320 (https://en.wikipedia.org/wiki/Samsung_Galaxy_Ace)


Since the Atrix is hdpi, and hdpi is a 1.5 multiplier, 200dp will take up 300px in real pixels, or approximately 1/3 (300/960) of the screen as you point out.


On the mdpi Ace, the 200dp translates evenly to 200px, which should be closer to 1/2 the screen. However, with the addition of the actionbar taking up screen real estate, it may seem like more.


The best way to deal with very small screens like the ace... well, my normal solution is to not support them very well, at least not on my first pass, as they are pretty rare. But if you want to, the best way is to provide alternate layouts.


For Example:


Create a folder named layout-large (or similar, see: http://developer.android.com/guide/topics/resources/providing-resources.html#Compatibility).


Make a copy of your existing xml file in that folder. (name must be exactly the same)


Modify the file in layout/ so that it works better on smaller screens.


Essentially, if the device has a "large" screen or above (where large is basically the standard these days), it will use the layout in the layout-large/ folder.


Otherwise, it will use the default layout in the layout/ folder.


If you think this explanation is not what is happening, please provide screen shots to verify that the layout is in fact not behaving like it should.



.

stackoverflow.comm

[android help] Need help on getting data from WAMS android


I'm trying to get my username & password from my WAMS (android) to check during login (my login part is at btn1). I not sure if I did it correctly. Please help me take a look at it and see what did I do wrongly. Thanks.



package mp.memberuse;

import java.net.MalformedURLException;
import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;

import com.microsoft.windowsazure.mobileservices.MobileServiceClient;
import com.microsoft.windowsazure.mobileservices.MobileServiceTable;
import com.microsoft.windowsazure.mobileservices.ServiceFilterResponse;
import com.microsoft.windowsazure.mobileservices.TableOperationCallback;
import com.microsoft.windowsazure.mobileservices.TableQueryCallback;

public class LoginRegister extends Activity {

Button btn1, btn2, btn3;
EditText tf1, tf2, tf3, tf4, tf5, tf6, tf7, tf8, tf9, tf10, tf11;
TextView tv1, tv2;

private MobileServiceClient mClient;
private MobileServiceTable mMembersTable;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

TabHost tabs = (TabHost) this.findViewById(R.id.lt2tabhost);
tabs.setup();

TabSpec ts1 = tabs.newTabSpec("Login");
ts1.setIndicator("Login");
ts1.setContent(R.id.c1);
tabs.addTab(ts1);

TabSpec ts2 = tabs.newTabSpec("Register");
ts2.setIndicator("Register");
ts2.setContent(R.id.c2);
tabs.addTab(ts2);

btn1 = (Button)findViewById(R.id.button1);
btn2 = (Button)findViewById(R.id.button2);
btn3 = (Button)findViewById(R.id.button3);

tf1=(EditText) findViewById(R.id.editText1);
tf2=(EditText) findViewById(R.id.editText2);
tf3=(EditText) findViewById(R.id.editText3);
tf4=(EditText) findViewById(R.id.editText4);
tf5=(EditText) findViewById(R.id.editText5);
tf6=(EditText) findViewById(R.id.editText6);
tf7=(EditText) findViewById(R.id.editText7);
tf8=(EditText) findViewById(R.id.editText8);
tf9=(EditText) findViewById(R.id.editText9);
tf10=(EditText) findViewById(R.id.editText10);

tv1=(TextView) findViewById(R.id.login);
tv2=(TextView) findViewById(R.id.register);

try {
// Create the Mobile Service Client instance, using the provided
// Mobile Service URL and key
mClient = new MobileServiceClient(
"https://*****.azure-mobile.net/",
"********************************",
this
);

// Get the Mobile Service Table instance to use
mMembersTable = mClient.getTable(Members.class);


} catch (MalformedURLException e) {
//createAndShowDialog(new Exception("There was an error creating the Mobile Service. Verify the URL"), "Error");
}

btn1.setOnClickListener(new View.OnClickListener(){
public void onClick(View v)
{
final String username, password;
username = tf1.getText().toString();
password = tf2.getText().toString();

mMembersTable.select("username", "password").execute(new TableQueryCallback()
{
public void onCompleted(List result, int count, Exception exception, ServiceFilterResponse response) {
if (exception == null)
{
for (Members mbs : result)
{
mbs.getUsername();
mbs.getPassword();

if(username.equals(mbs.getUsername()) && password.equals(mbs.getPassword()))
{
Intent intent = new Intent (LoginRegister.this, Map.class);
startActivity(intent);
}
}
}
else
{
tv1.setText("Invalid user");
}
}
});
}
});

btn2.setOnClickListener(new View.OnClickListener(){
public void onClick(View v)
{
String username, password, cpassword, fullname, nric, address, phone, email;
username = tf3.getText().toString();
password = tf4.getText().toString();
cpassword = tf5.getText().toString();
fullname = tf6.getText().toString();
nric = tf7.getText().toString();
address = tf8.getText().toString();
phone = tf9.getText().toString();
email = tf10.getText().toString();

if (mClient == null) {
return;
}

Members mbs = new Members();

mbs.setUsername(username);
mbs.setPassword(password);
mbs.setFullname(fullname);
mbs.setNric(nric);
mbs.setAddress(address);
mbs.setPhone(phone);
mbs.setEmail(email);

if(!password.equals(cpassword))
{
tv2.setText("Password & Confirm Password does not match.");
}
else if(username.equals("") || password.equals("") || cpassword.equals("") || fullname.equals("") || nric.equals("") || address.equals("") || phone.equals("") || email.equals(""))
{
tv2.setText("Do not leave any field empty.");
}
else
{
mMembersTable.insert(mbs, new TableOperationCallback()
{

public void onCompleted(Members entity, Exception exception, ServiceFilterResponse response)
{

if (exception == null)
{
tv2.setText("Register Complete.");
tf3.setText("");
tf4.setText("");
tf5.setText("");
tf6.setText("");
tf7.setText("");
tf8.setText("");
tf9.setText("");
tf10.setText("");
}
else
{
tv2.setText("Fail to register!");
tf3.setText("");
tf4.setText("");
tf5.setText("");
tf6.setText("");
tf7.setText("");
tf8.setText("");
tf9.setText("");
tf10.setText("");
}

}
});
}
}
});

btn3.setOnClickListener(new View.OnClickListener(){
public void onClick(View v)
{
tf3.setText("");
tf4.setText("");
tf5.setText("");
tf6.setText("");
tf7.setText("");
tf8.setText("");
tf9.setText("");
tf10.setText("");
}
});
}
}


.

stackoverflow.comm

[android help] Android, List Adapter returns wrong position in getView


I have found a mysterious problem that may be a bug! I have a list in my fragment. Each row has a button. List shouldn't respond to click however buttons are clickable.


In order to get which button has clicked I have created a listener and implement it in my fragment. This is the code of my adapter.



public class AddFriendsAdapter extends BaseAdapter {

public interface OnAddFriendsListener {
public void OnAddUserClicked(MutualFriends user);
}

private final String TAG = "*** AddFriendsAdapter ***";

private Context context;
private OnAddFriendsListener listener;
private LayoutInflater myInflater;
private ImageDownloader imageDownloader;
private List userList;

public AddFriendsAdapter(Context context) {
this.context = context;
myInflater = LayoutInflater.from(context);

imageDownloader = ImageDownloader.getInstance(context);
}

public void setData(List userList) {
this.userList = userList;

Log.i(TAG, "List passed to the adapter.");
}

@Override
public int getCount() {
try {
return userList.size();
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}

@Override
public Object getItem(int position) {
return null;
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;

if (convertView == null) {
convertView = myInflater.inflate(R.layout.list_add_friends_row, null);
holder = new ViewHolder();

Typeface font = Typeface.createFromAsset(context.getAssets(), "fonts/ITCAvantGardeStd-Demi.ttf");
holder.tvUserName = (TextView) convertView.findViewById(R.id.tvUserName);
holder.tvUserName.setTypeface(font);
holder.ivPicture = (ImageView) convertView.findViewById(R.id.ivPicture);
holder.btnAdd = (Button) convertView.findViewById(R.id.btnAdd);
holder.btnAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.e(TAG, "Item: " + position);
listener.OnAddUserClicked(userList.get(position));
}
});

convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}

holder.tvUserName.setText(userList.get(position).getName());
imageDownloader.displayImage(holder.ivPicture, userList.get(position).getPhotoUrl());

return convertView;
}

public void setOnAddClickedListener(OnAddFriendsListener listener) {
this.listener = listener;
}

static class ViewHolder {
TextView tvUserName;
ImageView ivPicture;
Button btnAdd;
}
}


When I run the app, I can see my rows however since my list is long and has over 200 items when i goto middle of list and click an item then returned position is wrong (it's something like 7, sometimes 4 and etc.).


Now what is the mystery? If I active on item listener of list from my fragment and click on row then correct row position will be displayed while on that row if I click on button then wrong position will be displayed.



listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView parent, View view, int position, long id) {
Log.e(TAG, "item " + position + " clicked.");
}
});


Result in logcat:



05-09 10:22:25.228: E/AddFriendsFragment(20296): item 109 clicked.
05-09 10:22:34.453: E/*** AddFriendsAdapter ***(20296): Item: 0


Any suggestion would be appreciated. Thanks



.

stackoverflow.comm

[android help] getting user location with a button click on google map


I am trying to find the user location with latitude and longitude. Is it possible to add a button to save the location (lat, long) and jump into another page? Or maybe get the image of the user location on the map. Do help me out on what to do. Thanks.



package mp.memberuse;

import android.app.Dialog;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class Map extends FragmentActivity {

GoogleMap googleMap;

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

// Getting Google Play availability status
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());

// Showing status
if(status!=ConnectionResult.SUCCESS)
{ // Google Play Services are not available

int requestCode = 10;
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
dialog.show();

}
else
{ // Google Play Services are available

// Getting reference to the SupportMapFragment of activity_main.xml
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

// Getting GoogleMap object from the fragment
googleMap = fm.getMap();

// Enabling MyLocation Layer of Google Map
googleMap.setMyLocationEnabled(true);

// Getting LocationManager object from System Service LOCATION_SERVICE
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

// Creating a criteria object to retrieve provider
Criteria criteria = new Criteria();

// Getting the name of the best provider
String provider = locationManager.getBestProvider(criteria, true);

// Getting Current Location
Location location = locationManager.getLastKnownLocation(provider);

LocationListener locationListener = new LocationListener()
{
public void onLocationChanged(Location location)
{
// redraw the marker when get location update.
drawMarker(location);
}

@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub

}

@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub

}

@Override
public void onStatusChanged(String provider, int status,
Bundle extras) {
// TODO Auto-generated method stub

}
};

if(location!=null)
{
//PLACE THE INITIAL MARKER
drawMarker(location);
}
locationManager.requestLocationUpdates(provider, 20000, 0, locationListener);
}
}
private void drawMarker(Location location)
{
googleMap.clear();
LatLng currentPosition = new LatLng(location.getLatitude(),
location.getLongitude());
googleMap.addMarker(new MarkerOptions().position(currentPosition).snippet("Lat:" + location.getLatitude() + "Lng:"+ location.getLongitude()).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))
.title("ME"));
}
Location location;
LatLng currentPosition = new LatLng(location.getLatitude(),location.getLongitude());
String myLocation = currentPosition.toString();

void saveLoc(){
if ( myLocation!=null){
// save Location in SharedPreference or a Database here
SharedPreferences prefs = getSharedPreferences("myPreferences",Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putString("myLocation", myLocation);
editor.commit();
// Start new activity
Intent intent = new Intent(Map.this, SendMessage.class);
startActivity(intent);
}
}


Logcat.txt



05-09 02:01:54.280: D/dalvikvm(508): GC_EXTERNAL_ALLOC freed 51K, 53% free 2576K/5379K, external 3129K/3266K, paused 72ms
05-09 02:01:57.891: W/KeyCharacterMap(508): No keyboard for id 0
05-09 02:01:57.891: W/KeyCharacterMap(508): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
05-09 02:02:34.450: W/KeyCharacterMap(508): No keyboard for id 0
05-09 02:02:34.450: W/KeyCharacterMap(508): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
05-09 02:02:34.490: D/dalvikvm(508): GC_CONCURRENT freed 1486K, 58% free 3019K/7111K, external 3430K/4246K, paused 6ms+4ms
05-09 02:02:46.381: I/dalvikvm(508): Total arena pages for JIT: 11
05-09 02:02:47.931: D/dalvikvm(508): GC_CONCURRENT freed 1315K, 59% free 2950K/7111K, external 3430K/4246K, paused 5ms+4ms
05-09 02:02:48.281: D/AndroidRuntime(508): Shutting down VM
05-09 02:02:48.281: W/dalvikvm(508): threadid=1: thread exiting with uncaught exception (group=0x40015560)
05-09 02:02:48.300: E/AndroidRuntime(508): FATAL EXCEPTION: main
05-09 02:02:48.300: E/AndroidRuntime(508): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{mp.memberuse/mp.memberuse.Map}: java.lang.NullPointerException
05-09 02:02:48.300: E/AndroidRuntime(508): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
05-09 02:02:48.300: E/AndroidRuntime(508): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-09 02:02:48.300: E/AndroidRuntime(508): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-09 02:02:48.300: E/AndroidRuntime(508): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-09 02:02:48.300: E/AndroidRuntime(508): at android.os.Handler.dispatchMessage(Handler.java:99)
05-09 02:02:48.300: E/AndroidRuntime(508): at android.os.Looper.loop(Looper.java:123)
05-09 02:02:48.300: E/AndroidRuntime(508): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-09 02:02:48.300: E/AndroidRuntime(508): at java.lang.reflect.Method.invokeNative(Native Method)
05-09 02:02:48.300: E/AndroidRuntime(508): at java.lang.reflect.Method.invoke(Method.java:507)
05-09 02:02:48.300: E/AndroidRuntime(508): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-09 02:02:48.300: E/AndroidRuntime(508): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-09 02:02:48.300: E/AndroidRuntime(508): at dalvik.system.NativeStart.main(Native Method)
05-09 02:02:48.300: E/AndroidRuntime(508): Caused by: java.lang.NullPointerException
05-09 02:02:48.300: E/AndroidRuntime(508): at mp.memberuse.Map.(Map.java:114)
05-09 02:02:48.300: E/AndroidRuntime(508): at java.lang.Class.newInstanceImpl(Native Method)
05-09 02:02:48.300: E/AndroidRuntime(508): at java.lang.Class.newInstance(Class.java:1409)
05-09 02:02:48.300: E/AndroidRuntime(508): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-09 02:02:48.300: E/AndroidRuntime(508): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
05-09 02:02:48.300: E/AndroidRuntime(508): ... 11 more
05-09 02:02:55.531: I/Process(508): Sending signal. PID: 508 SIG: 9


.

stackoverflow.comm

[android help] Android-NDK: Fatal signal 11 (SIGSEGV) on Windows 64 only

Android-NDK: Fatal signal 11 (SIGSEGV) on Windows 64 only - 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.

















When I run the project on my Mac everything is fine. The same project run on Windows 64 I crash upon start.


Both use NDK8e. How can I find out what is the difference?


Windows 64



05-09 04:25:51.310: D/dalvikvm(16908): Shared lib '/data/data/com.evotegra.aCoDriver/lib/libjsqlite.so' already loaded in same CL 0x4219e688
05-09 04:25:51.335: A/libc(16908): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 16908 (tegra.aCoDriver)


Mac



05-09 04:49:09.070: D/dalvikvm(307): Shared lib '/data/data/com.evotegra.aCoDriver/lib/libjsqlite.so' already loaded in same CL 0x4219d5f8
05-09 04:49:40.735: V/SoundPoolThread(27591): beginThread















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










default







.

stackoverflow.comm

[General] SOS, Need Help to find my phone!!!


Who can help me solve my problem.
My LG E730 smartphone is have in someones of my friends without a sim card but with an internet connection over WiFi.
How to calculate from where my smartphone connecting to internet, and how to find IP address of the phone?
P.S. I can install any application on it over Google Play in my account using browser!

What app can help me to track where my smartphone is??



.

forum.xda-developers.com

[General] Tab 2 / general Questions


Hi, I have some questions. I would appreciate any assistance

Samsung Tab 2 (7.0, 3113 Wifi with IR)

Android vers 4.1.1 (afaik latest for this device)

1) Could anyone recommend a case? I need something that can flip (prefer a magnet based lock). It needs to be able to take massive impacts (ie. drop from onto cement from 2 meters) from EVERY angle, including corners. I also need it real quick (within 12 days) - so big department stores are good, and Amazon Prime is good (I live in Canada)

2) Is there any way to adjust screen dim time?

3) Is there any way to have the screen automatically turn on/off using the sensors? Namely, the light and proximity sensors. Ex. proximity sensor: IF object is detected within 2 cm continuously for 5 seconds, shut off screen. IF object is removed, turn screen on. I had a Nexus 7 with a magnetic flip case, in which the Nexus 7 would automatically turn on when the flap was opened, and turn off when the flap was closed, as sensed by its magnetometer.

4) Could I get detailed instructions into the installation of Cyanogenmod? What exactly is it good for? Any other BIOSes worth looking into?

5) A suggestion for a fast PDF reader? I need something that will process large, coloured images very quickly (a large sized travel book).

6) Any tweaks to maximize speed? I just bought it 2 days ago and its not as fast as I'd like even out of the box.

7) Is there any way to get better camera quality? I want to use it in the place of a discrete camera (personal reasons).

Thanks in advace. Any help with even one of the questions would be great.



.

forum.xda-developers.com

[android help] How to clickable list's row and button in row in listview?


I am using a listview in my Android program.


I have row. 1) i have custom row in button and i want to when click button then open the alert box and this row clicked then open the new activity but Only one button clicked not row clicked . how to possible in this case. my code in below.


Thank you.



public class AlMessagesAdapter extends ArrayAdapter {

private LayoutInflater inflator;
private ArrayList userlist;

public AlMessagesAdapter(Activity context, ArrayList list) {
super(context, R.layout.custom_list, list);

this.userlist = list;
inflator = context.getLayoutInflater();
}

@Override
public View getView(final int position, View convertView, ViewGroup parent) {

ViewHolder holder = null;
if (convertView == null) {
convertView = inflator.inflate(R.layout.custom_list, null);
holder = new ViewHolder();
holder.title = (TextView) convertView.findViewById(R.id.tvName);
holder.date_cr = (TextView) convertView.findViewById(R.id.tvDate);
holder.img = (ImageView)convertView.findViewById(R.id.ivIcon);
holder.tokenBtn = (Button)convertView.findViewById(R.id.tokenBtn);
convertView.setTag(holder);
convertView.setTag(R.id.tvName, holder.title);
convertView.setTag(R.id.tvDate, holder.date_cr);
convertView.setTag(R.id.ivIcon,holder.img);
convertView.setTag(R.id.tokenBtn,holder.tokenBtn);

} else {
holder = (ViewHolder) convertView.getTag();
}

String token = userlist.get(position).getToken();

Log.v("MessageList", "token:" + token);

token = token.substring(0,token.length()-3);

holder.title.setText(userlist.get(position).getName()+"("+token+")");

String type_data = userlist.get(position).getType().toString();

if((type_data.equals("text")) || (type_data.equals("photo")))
{
Log.v("log", " if text photo ");
holder.date_cr.setText(userlist.get(position).getType()+":Received "+userlist.get(position).getCreated_date());
holder.tokenBtn.setVisibility(View.VISIBLE);
list.setItemsCanFocus(true);
}
else if(type_data.equals("out"))
{
Log.v("log", " else out ");
holder.date_cr.setText(userlist.get(position).getType()+":Sent "+userlist.get(position).getCreated_date());
holder.tokenBtn.setVisibility(View.GONE);
}

if(type_data.equals("text"))
{
Log.v("log", " if text ");
holder.img.setBackgroundResource(R.drawable.chatmessage);

}
else if(type_data.equals("photo"))
{
Log.v("log", " ese if photo ");
holder.img.setBackgroundResource(R.drawable.photomessage);

}
else if(type_data.equals("out"))
{
Log.v("log", " ese if out ");
holder.img.setBackgroundResource(R.drawable.outmessafe);
}


if(position%2==0)
{
convertView.setBackgroundResource(R.drawable.whitebackground);
}
else
{
convertView.setBackgroundResource(R.drawable.greybackground);
}

holder.tokenBtn.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.v("log_tag"," token button clicked");
}
});


return convertView;
}

class ViewHolder {
protected ImageView img;
protected TextView date_cr;
protected TextView title;
protected Button tokenBtn;
}
}


and list click event in below::



list.setOnItemLongClickListener(new OnItemLongClickListener() {

@Override
public boolean onItemLongClick(AdapterView arg0, View arg1,
int position, long arg3) {
// TODO Auto-generated method stub

msg = userLIstArray.get(position).getMessage();
token = userLIstArray.get(position).getToken();
type = userLIstArray.get(position).getType();
int msgId = userLIstArray.get(position).getMessageid();
token = token.substring(0,token.length()-3);
int token_value = Integer.parseInt(token) * 1000;

if(type.equals("text"))
{
Log.v("log", " if in text to Display " + msg + " token "+token);
Intent i = new Intent(MessagesList.this,DisplayPopupActivity.class);
i.putExtra("msg", msg);
i.putExtra("token", token);
i.putExtra("msgid", msgId);
startActivity(i);

}
else if(type.equals("photo"))
{
Log.v("log", " else in IMage to Display " + msg + " token "+token);

Log.v("log","token "+token+" type "+type + " position "+position + "msgId "+ msgId);

Intent i = new Intent(MessagesList.this,DisplayImageActivity.class);
i.putExtra("imgData", msg);
i.putExtra("token", token);
i.putExtra("msgid", msgId);
startActivity(i);

//Log.v("log"," Message" +message);
//Toast.makeText(AllMessageActivity.this, "Message "+message, Toast.LENGTH_LONG).show();
}

return false;
}
});
}


.

stackoverflow.comm

[android help] how to use simple getter and setter with android


I have a class country with an arraylist that stores countries. I have created a get and set to add and get items from specified indexes from the array list but i wont work. Whenever i call an index from the arraylist i get an out of bounds exception because the array is empty or at least seems to be.



public class country extends Application {

public ArrayList countryList = new ArrayList();
public String Name;
public String Code;
public String ID;

public country()
{

}

public country(String name, String id, String code)
{
this.Name = name;
this.ID = id;
this.Code = code;
}

public void setCountry(country c)
{
countryList.add(c);
}

public country getCountry(int index)
{
country aCountry = countryList.get(index);
return aCountry;
}


to call the setter i use.



country ref = new country();

ref.setCountry(new country (sName, ID, Code));


then when i want to get an index



String name = ref.countryList.get(2).Name;


i have done the same thing but used a local arraylist and it populated fine and i was able to display the names so the datasource isnt the problem its whatever im doing wrong setting and getting the data inside the arraylist in the country class



.

stackoverflow.comm

[android help] Fragment and Activity Issues


I am trying to create a simple set of screens in an android app. The app begins with a menu screen with buttons. After a choice is made I then want to launch an activity built with 2 fragments (one for player 1 and another for player 2). However when I try and start the activity with the fragments I get an error in the android emulator.


Here is my code so far:


The main menu code



import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;

public class MainMenuActivity extends Activity {

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

@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, menu);
return true;
}

// load up 1v1 duel activity
public void beginRegularDuel(View view)
{
Intent intent = new Intent(this, OneVsOneDuelActivity.class);

startActivity(intent);
}

}


The 1v1 Duel Code:



package com.PigRam.magichelper;
import android.app.Activity;
import android.os.Bundle;

public class OneVsOneDuelActivity extends FragmentActivity{

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);

setContentView(R.layout.one_vs_one_view);
}
}


The Player One fragment code:



package com.PigRam.magichelper;

import android.annotation.TargetApi;
import android.app.Fragment;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class PlayerOneDuelFragment extends Fragment {

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
return inflater.inflate(R.layout.one_vs_one_view, container, false);
}
}


And Player Two:



package com.PigRam.magichelper;

import android.annotation.TargetApi;
import android.app.Fragment;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class PlayerTwoDuelFragment extends Fragment{

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
return inflater.inflate(R.layout.one_vs_one_view, container, false);
}
}


And layout for main menu



xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >

android:id="@+id/main_menu_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/main_menu_title"
android:textSize="50sp" />

android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >

android:id="@+id/regular_duel"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:text="@string/regular_duel"
android:onClick="beginRegularDuel" />

android:id="@+id/two_headed_dragon"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="@string/two_headed_dragon" />






And the Duel Screen layout




android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:baselineAligned="false">

android:id="@+id/player_one_fragment"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"/>

android:id="@+id/player_two_fragment"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent" />



Also the manifest




package="com.PigRam.magichelper"
android:versionCode="1"
android:versionName="1.0" >

android:minSdkVersion="8"
android:targetSdkVersion="17" />

android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

android:label="@string/app_name" >







android:label="@string/app_name">







And last but not least here is the error log:


05-09 09:40:18.696: D/gralloc_goldfish(1521): Emulator without GPU emulation detected. 05-09 09:40:22.746: D/AndroidRuntime(1521): Shutting down VM 05-09 09:40:22.756: W/dalvikvm(1521): threadid=1: thread exiting with uncaught exception (group=0x40a71930) 05-09 09:40:22.916: D/dalvikvm(1521): GC_CONCURRENT freed 191K, 11% free 2634K/2956K, paused 75ms+122ms, total 303ms 05-09 09:40:22.926: E/AndroidRuntime(1521): FATAL EXCEPTION: main 05-09 09:40:22.926: E/AndroidRuntime(1521): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.PigRam.magichelper/com.PigRam.magichelper.OneVsOneDuelActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class fragment 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.app.ActivityThread.access$600(ActivityThread.java:141) 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.os.Handler.dispatchMessage(Handler.java:99) 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.os.Looper.loop(Looper.java:137) 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.app.ActivityThread.main(ActivityThread.java:5041) 05-09 09:40:22.926: E/AndroidRuntime(1521): at java.lang.reflect.Method.invokeNative(Native Method) 05-09 09:40:22.926: E/AndroidRuntime(1521): at java.lang.reflect.Method.invoke(Method.java:511) 05-09 09:40:22.926: E/AndroidRuntime(1521): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 05-09 09:40:22.926: E/AndroidRuntime(1521): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 05-09 09:40:22.926: E/AndroidRuntime(1521): at dalvik.system.NativeStart.main(Native Method) 05-09 09:40:22.926: E/AndroidRuntime(1521): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class fragment 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 05-09 09:40:22.926: E/AndroidRuntime(1521): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270) 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.app.Activity.setContentView(Activity.java:1881) 05-09 09:40:22.926: E/AndroidRuntime(1521): at com.PigRam.magichelper.OneVsOneDuelActivity.onCreate(OneVsOneDuelActivity.java:13) 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.app.Activity.performCreate(Activity.java:5104) 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) 05-09 09:40:22.926: E/AndroidRuntime(1521): ... 11 more 05-09 09:40:22.926: E/AndroidRuntime(1521): Caused by: java.lang.ClassCastException: com.PigRam.magichelper.PlayerOneDuelFragment cannot be cast to android.support.v4.app.Fragment 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.support.v4.app.Fragment.instantiate(Fragment.java:394) 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.support.v4.app.Fragment.instantiate(Fragment.java:369) 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272) 05-09 09:40:22.926: E/AndroidRuntime(1521): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676) 05-09 09:40:22.926: E/AndroidRuntime(1521): ... 21 more


Sorry for all the code but this is really bugging me. I am new to Android programming so please help me out!


Thanks.



.

stackoverflow.comm

[android help] App crashes on mobile device after using ProGuard

java - App crashes on mobile device after using ProGuard - 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.

















After successfully using ProGuard on my application, it crashes on the startup on my mobile device. I use standard configuration of proguard: ${sdk.dir}/tools/proguard/proguard-android.txt


And logcat says something like this: E/AndroidRuntime(13441): at packagename.q.doInBackground(Unknown Source)


And then some App crashed errors etc.


Why does it not find my Source in doInBackground? Its a simple AsyncTask. Can anyone help me?



















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










lang-java







.

stackoverflow.comm

[android help] android.os.NetworkOnMainThreadException with a AsyncTask


I'm trying to connect a socket with Android. I know that you can't open network-connections from MainThread. I have created an AsyncTask to do it. I have created and private class inside of the main class, I have seen some examples on internet about that.


Could someone help me about what it's wrong?? I guess that it's a error in the way I'm trying to connect because I have connected to the server with a normal Java class. I have edited the manisfest to give the necessary permissions.


If someone has any advise about a better way to do it, it would be great.



public class MainActivity extends Activity {

private ObjectInputStream input;
private ObjectOutputStream output;
private Button buttonCreateRoom;



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

buttonCreateRoom = (Button)findViewById(R.id.buttonCreate);


//buttons
buttonCreateRoom.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View view) {
onClickButton(ConstantsRooms.CREATE_ROOM);
}
});


}

private void onClickButton(int numberButton){
RequestMessage request = null;

switch (numberButton) {
....
}

AsyncButtons asyncButtons = new AsyncButtons();
asyncButtons.execute(request);

}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}




//Botones
private class AsyncButtons extends AsyncTask {
private Socket socket;

@Override
protected Void doInBackground(RequestMessage... params) {
RequestMessage request;
ResponseMessage response;
Void v = null;
try{

request = params[0];
output.writeObject(request);
output.flush();

response = (ResponseMessage)input.readObject();

...
}


@Override
protected void onPreExecute() {

try{
// Setup networking
**socket = new Socket(ConstantsRooms.SERVER_ADDRESS, ConstantsRooms.PORT_PUBLIC); -->ERROR**
socket.setTcpNoDelay(true);
output = new ObjectOutputStream(socket.getOutputStream());
output.flush();
input = new ObjectInputStream(socket.getInputStream());

}catch (Exception exp){
Log.e(TAG, "Excepcion socket ---");
exp.printStackTrace();
}
}
}

}


.

stackoverflow.comm

[android help] Convert string to ASCII value in java

android - Convert string to ASCII value in java - 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


String name = "admin";


then i do


String char = name.substring(0,1); //char="a"


I want to convert the char to it's ASCII value (97), how can i do this in java?


























Instead of this:



String char = name.substring(0,1); //char="a"


You should use the charAt() method.



char c = name.charAt(0); // c='a'
int ascii = (int)c;






















Very simple. Just cast your char as an int.



char character = 'a';
int ascii = (int) character;


In your case, you need to get the specific Character from the String first and then cast it. Though cast is not required explicitly, but its improves readability.



int ascii = character; // Even this will do the trick.
























Just cast the char to an int.



char character = 'a';
int number = (int) character;


The value of number will be 97.






















It's simple, get the character you want, and convert it to int.



String name = "admin";
int ascii = name.charAt(0);
























Convert the char to int.



String name = "admin";
int ascii = name.toCharArray()[0];


Also :



int ascii = name.charAt(0);





















If you wanted to convert the entire string into concatenated ASCII values then you can use this -



String str = "abc"; // or anything else

StringBuilder sb = new StringBuilder();
for (char c : str.toCharArray())
sb.append((int)c);

BigInteger mInt = new BigInteger(sb.toString());
System.out.println(mInt);


wherein you will get 979899 as output.


Credit to this.


I just copied it here so that it would be convenient for others.






















just a different approach



String s = "admin";
byte[] bytes = s.getBytes("US-ASCII");


bytes[0] will represent ascii of a.. and thus the other characters in the whole array.




















lang-java







.

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