Wednesday, December 25, 2013

How do I display a string in an Android app? [android help]


How do I display a string in an Android app?



I'm confused on exactly what your problem is here but you have a couple problems if you want your TextView to display the message. This line here



TextView textView = new TextView(this);


will create a new TextView, not reference the one you have in your xml. And it won't show because you haven't added it to your contentView. So, when you call setContentView(R.layout.activity_display_message); what will be shown is what is in activity_display_message. If you want to access that View then you need to give it an id in your xml file and access it with findViewById(). So give it an id



android:id="@+id/tv1" // give it an id here
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/entered_message" />


then access it after calling setContentView(...)



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

Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
setContentView(R.layout.activity_display_message);
TextView tv = (TextView) findViewById(R.id.tv1); // reference it here with the id you gave it in the xml

}


Now that you have referenced the TextView, you can call setText(), setTextSize(), etc.. if need be.


I'm not exactly sure what String you want where so its hard to give much more help without a better explanation. But note that



String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);


will assign the message variable to whatever is passed in your Intent from the calling Activity.



Read more

stackoverflow.comm



Gps Location updates in android is not working [android help]


Gps Location updates in android is not working



From Android official site I have downloaded Location services example & did run in the real device. Every time onLocationChanged method is returning Network's Latitude & Longitude but not accurate GPS location. How to achieve accurate GPS locations from the new android Location API.


Here is my service code



package com.example.locationservice;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.location.LocationClient;
import com.google.android.gms.location.LocationRequest;

public class MDFYLocationUpdate extends Service implements
LocationListener,
GooglePlayServicesClient.ConnectionCallbacks,
GooglePlayServicesClient.OnConnectionFailedListener,
com.google.android.gms.location.LocationListener {

LocationClient mLocationClient;
private LocationRequest mLocationRequest;
public static Context c;
final String BROADCAST_ACTION ="current_location";
public static final String TAG="Location";
// Milliseconds per second
private static final int MILLISECONDS_PER_SECOND = 1000;
// Update frequency in seconds
public static final int UPDATE_INTERVAL_IN_SECONDS = 5;
// Update frequency in milliseconds
private static final long UPDATE_INTERVAL = 10000;
//MILLISECONDS_PER_SECOND * UPDATE_INTERVAL_IN_SECONDS;
// The fastest update frequency, in seconds
private static final int FASTEST_INTERVAL_IN_SECONDS = 1;
// A fast frequency ceiling in milliseconds
private static final long FASTEST_INTERVAL =
MILLISECONDS_PER_SECOND * FASTEST_INTERVAL_IN_SECONDS;

@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
mLocationRequest =LocationRequest.create();

mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
// Set the update interval to 5 seconds
mLocationRequest.setInterval(UPDATE_INTERVAL);
// Set the fastest update interval to 1 second
mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
servicesConnected();
mLocationClient =new LocationClient(this, this, this);
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}


@Override
public void onConnected(Bundle connectionHint) {
// TODO Auto-generated method stub

Log.d(TAG, "onconnected");
mLocationClient.requestLocationUpdates(mLocationRequest, this);
}
@Override
public void onDisconnected() {
// TODO Auto-generated method stub
Log.d(TAG, "onsisconnect");
// Destroy the current location client
mLocationClient = null;
}
@Override
public void onConnectionFailed(ConnectionResult result) {
// TODO Auto-generated method stub

}

private boolean servicesConnected() {
// Check that Google Play services is available
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
// If Google Play services is available
if (ConnectionResult.SUCCESS == resultCode) {

return true;
} else {

return false;
}
}

@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
Log.d(TAG, "onLocationChanged");
Log.d(TAG, "Lat = " + location.getLatitude() + " Lng = " + location.getLongitude());
Logger.writeLog("Lat = " + location.getLatitude() + " Lng = " + location.getLongitude() + " == "+BasicDeviceInformation.getCurrentDate());

}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
Log.d(TAG, "onStartCommand");
mLocationClient.connect();
return super.onStartCommand(intent, flags, startId);
}
@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

}
}


Read more

stackoverflow.comm



Google Plus +1 an Google Play application? [android help]


Google Plus +1 an Google Play application?



My question is regarding the Google Play +1 button now available inside Android apps. I managed to include a fully functional +1 button inside my app, however it takes an URL as a parameter to "+1", and my question is regarding which URL should I use.


Watching the Google I/O I saw that Google will recommend apps based on what your friends +1'd, so what I'm trying to archive is creating an +1 button that will have the same behavior as +1'ing though the Google Play app details page.


Should I use the Google Play URL? What else can I do?


Thanks for responding.



Read more

stackoverflow.comm



How to begin with Android Programming? [android help]


How to begin with Android Programming?


How to begin with Android Programming? - Stack Overflow















Take the tour ×

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
















I'm an ASP Developer for a 2 years. now, i want to start with Android, but i don't know the essential of Android and have some questions about these as you seen below:


  1. What is the best reference to starting with Android?

  2. What is the best IDE to developing Android and testing the Android softwares. (my mobile is Nokia E-52 based on 'Symbian s60 v3' and i cannot test these Android softwares on a mobile platform)

  3. I want to starting Android on Windows


Big Thanks to everyone.


























What is the best reference to starting with Android? ans:- You can start with developer.android.com. It is very good whereyou can start android.


What is the best IDE to developing Android and testing the Android softwares. ans:- Eclipse IDE is best for android development and for testing you need not to buy any device at starting, you can use emulator for testing. Once you have done with training you may choose any androi ddevice depending on your requirements.


this might help you also... Android UI Design-https://www.facebook.com/groups/AndroidUI/ Android group- https://www.facebook.com/groups/andorid/ Joining here might help you.























I find this tutorial very good to start with Android: http://www.kilobolt.com/android-application-development-tutorial.html.


Official Google IDE for Android: http://developer.android.com/sdk/installing/studio.html (IntelliJ IDEA bundle). You can also use Eclipse and its Android plugin.




















default






Read more

stackoverflow.comm



Tuesday, December 24, 2013

Touch point coordinates with respect to Image after pinch zoom [android help]


Touch point coordinates with respect to Image after pinch zoom



How to calculate the coordinates with respect to image after zoom the image? To zoom the image I followed the url: https://github.com/MikeOrtiz/TouchImageView/blob/master/src/com/example/touch/TouchImageView.java.


if we touch the image at particular point before Zoom then corresponding values are



point:(3,2)
top left corner of image:(0,0)
top left corner of screen:(0,0)
scale factors:(1.25,0.98)


After zoom the image:


if we drag the image until the image top left corner coincides the screen top left corner and touch image exactly at same touch point(before pinch) then



point:(540,220)
top left corner of image:(0,0)
top left corner of screen:(0,0)
scale factors:(4.78,2.67)


if we drag the image until the image top right corner coincides with the screen top right corner and touch image exactly at same touch point(before pinch) then



point:(1080,340)
top left corner of screen:(0,0)
top left corner of image:(-2430,0)
scale factors:(4.78,2.67)


if we drag the image until the image bottom left corner coincides with the screen bottom left corner and touch image exactly at same touch point(before pinch) then



point:(670,80)
top left corner of screen:(0,0)
top left corner of image:(0,-890)
scale factors:(4.78,2.67)


if we drag the image until the image bottom right corner coincides with the screen bottom right corner and touch image exactly at same touch point(before pinch) then



point:(456,274)
top left corner of screen:(0,0)
top left corner of image:(-2430,-890)
scale factors:(4.78,2.67)


if we set the image over the screen [ not to set the any corner]



point:(743,146)
top left corner of screen:(0,0)
top left corner of image:(-1280,-423)
scale factors:(4.78,2.67)


In all the above scenarios I am getting the coordinates in touch event as



x_cord=event.getX();
y_cord=event.getY();


The touch points I am getting are with respect to the screen.


How can I calculate the touch points according to the Image?


Thanks & Regards mini.



Read more

stackoverflow.comm



Saturday, November 30, 2013

Activate setting not showing during ActiveSync config [General]


Activate setting not showing during ActiveSync config



Hi all,

I have a phone where Im trying to configure ActiveSync. It all goes "smoothly" because the account can be configured. The problem is when I try to view email on the configured account. It says that security policies have to be updated but I dont know where to go. I tried to remove and add the account again but I never see the "Activate" prompt where Im supposed to accept the security policies. Therefore, I dont see the Email app as a device administrator as I do on all the other users I have configured their accounts for.

Thanks in advance!



Read more

forum.xda-developers.com



Widget for Official Twitter App Not Updating [General]


Widget for Official Twitter App Not Updating



i noticed the widget for the official twitter app does not update at startup unless i open the app. yes, sync data is on and sync interval is set. in addition, the phone was reset and reformatted with no avail. also installed it on another device with same results. even though the widget does not update, i still get dm, mention, favorite, and retweet notifcations. strange.

the facebook widget will always update at startup. i also use the seesmic widget which updates at startup. difference between facebook and seesmic is that seesmic has an option in the settings, "launch at startup" in "misc". after the device is turned on and completes loading up, the app does not open but starts running in the background. going back to facebook, it doesnt have an option like that. regardless, it starts running in background.

finally, the question. how do we get the twitter app to run in the background at startup so the widget can update?

btw, already tried 3 different startup manager apps but they open the twitter app at startup. it will get the widget to udpate because the app is now opened but thats not what im looking for.



Read more

forum.xda-developers.com



I need help asap! [General]


I need help asap!



I have a Samsung Galaxy S3, US Cellular SCH-R530. I recently switched from apple, and I was getting bad signal. My friend said that he would fix it, and he tried downgrading my phone from 4.3 Jelly Bean to 4.2 Jelly Bean. And now my phone is stuck in "Firmware upgrade encountered an issue. Please select recovery mode in Kies & try again. I use my phone daily, and for a lot of purposes. He said he didn't know how to fix it, and kind of left me hanging without a phone. SO I really need to know how to fix this. Please anyone help me!



Read more

forum.xda-developers.com



Return Nexus 4 to darker Holo theme post KitKat? Possible? [General]


Return Nexus 4 to darker Holo theme post KitKat? Possible?



Well, just got my Nexus 4 upgraded to KitKat and frankly the bright white backgrounds hurt the hell out of my eyes (I have bad eyes) especailly on the formerly nice and dark holo-themed Dialer app. Is there any way to get the lovely and easy to look at grey/black and blue holo theme back for the dialer? This new stark white nonsense that's been forced on me actually causes me physical pain. I know this won't be a problem for many, but I just want my dark theme back if anyone can point me in the right direction



Read more

forum.xda-developers.com



Friday, November 29, 2013

Phone-to-PC connection app [General]


Phone-to-PC connection app



Hi folks.

Big hands + small phone = need for a GOOD phone-to-PC connection app.

Phone is a Medion E4002 (bought from Aldi) running Android 4.1.1. Does everything I want and great value for money.

I've tried a few apps but so far not found anything that easily allows me to do all my phone editing on the PC screen – mainly extensive contacts editing, but also file transfer etc. Texting is a big one too, as I need to frequently send text messages to groups.

I want an app that loads when I want to use it, not when it thinks it's needed – some are really annoying in this respect.

I sit at my desk all day with phone beside me so connection will always be via USB cable. Don't care about other connection types (Bluetooth, etc).

Any suggestions?



Read more

forum.xda-developers.com



Get the length of video recorded so far (or get accurate start time) [android help]


Get the length of video recorded so far (or get accurate start time)


java - Get the length of video recorded so far (or get accurate start time) - 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 want to synchronize other sensor data with the video I'm recording, and so I'd like to record "how far am I into the video" when the sensor is triggered. Is there any way to do this? I couldn't find an appropriate method on the MediaRecorder class.


Another solution would be to just get the precise start time of the video recording, but my tests show that the video starts ~1sec after calling mediarecorder.start, but it's not consistent.


























You have raised an interesting topic.
If you refer to the documentation in the developer page, the following diagram states the recording is supposed to start when the start() method is called.


enter image description here
Your solution is supposed to be correct albeit there is a lag up to 1 sec. I would do it the same way
I went through the MediaRecorder class methods, the only method that seems to be useful is the callback setOnInfoListener().
Set it and see if you will get some kind of information when the recording starts! I haven't tried it yet though.




















lang-java






Read more

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