Tuesday, April 9, 2013

[android help] Hide warnings in layout files

android - Hide warnings in layout files - Stack Overflow




















I updated Eclipse and SDK and now in every xml file the TextViews have the warning "Consider making the text value selectable by specifying android:textIsSelectable="true"".


Is it possible to hide the warnings, I hate to have my project with a lot of yellow exclamation marks.





























Go to the propeties of your project. Go to Android Lint Preferences. Search for SelectableText and change the severity to ignore.


You can also do this in Eclipse preferences for all projects.























There is a good reason for this warning. By just disabling it, you are basically ignoring user interface guidelines of Android and you are not using the full potential of the user interface of your app. Therefore looking at each text view and explicitly setting this attribute to either false or true will increase the quality of your app.






















The selected answer is the correct one...


However should you decide to go with Lint be aware that not every android target supports this tag.


I discovered this the hard way when I followed it's advice and received "No resource identifier found for attribute 'textIsSelectable' in package 'android'" as an error when it tried to compile the layout XML values.


Note I was targeting Android 2.2




















default







.

stackoverflow.comm

[android help] Bizarre exceptions being thrown in android activity


So, I have an android app to finish making for a project, the same one as I asked questions about here before but this time I'm having trouble with a completely different aspect. Since the app is about Pokémon, in one activity I have some TextViews, EditTexts and a button set up to make an IV calculator. If you're curious and don't know what "IVs" are in Pokémon, google it of course. Anyway, getting back on track...this image here I put together highlights my problem (http://oi45.tinypic.com/faodvk.jpg)


Above the boxed line you see there is a ClassCastException thrown saying cannot cast from type TextView to EditText...I know what that means in a general sense but I cannot fathom why it is occurring here because as you can see in the relevant line of code (which i pasted into the image) the part of that line that involves casting is casting from View (return type of findViewById) to EditText. The arg R.id.EditText06 IS referring to an EditText in my activity so I don't see where the bad casting attempt is supposedly occurring. Just for a little clarification of the context of this, this is part of stuff coded into the OnClickListener of the button.


Apologies if this question seems perhaps incomplete as regards content shown about the problem but it is quite late for me (so much so that I'm going to bed upon posting this) and please do ask for me to post other stuff if you feel you need it to try to help me.



.

stackoverflow.comm

[android help] Extend AsyncTask with radioGroup

android - Extend AsyncTask with radioGroup - Stack Overflow




















How can I use RadioGroup in class that extends AsyncTask ?


I also tried to use AsyncTask as inner class but didnt work. It gives constructor RadioGroup(..) undefined error !



final RadioGroup rg = new RadioGroup(this);

























that's impossible because RadioGroup is Android SDK class, even if you can, how do you start the AsyncTask? Does you want invoke an event when the RadioButton on? What's your meaning?




















default







.

stackoverflow.comm

[android help] Android tutorials for OpenGL with API level 10


I am currently trying to learn how to use OpenGLes in Android, but all of the tutorials I have found do not use API level 10. (i.e. Gingerbread/2.3)


EDIT: Well, at least they say they use it, but when I build it gives me errors as if it isn't there...


They require EGLConfig in setting the renderer and surface. Example:



public void onSurfaceCreated(GL10 gl, EGLConfig config)...


Taken from this tutorial.


Would anyone know a solution to this, or a reference to a tutorial that does this?



.

stackoverflow.comm

[General] wi fi connection problem on my S3 after ypgrading to 4.1.2


Hi,
i just got my phone 3 days ago, when i bought it it was working properly and i had no problem with WiFi even with 4.1.2, but since yesterday it started refusing to join some wifi networks, even at my home, it was connecting normally then it doesn`t want to connect at all
what i noticed iis that i might need to downgrade my software to 4.1.1, so how can i do this safely, and is there any other option to solve this problem?
regards



.

forum.xda-developers.com

[android help] Set the side of an image when using android:drawable____ in a button


If you want to define the accuracy size of the drawable, You should use Java code instead of android:drawableLeft



Drawable dw = getResources().getDrawable(R.drawable.ic);
dw.setBounds(0, 0, 100, 100); // set the size of the drawable to 100*100

button.setCompoundDrawables(dw, null, null, null);


because of



android:drawableLeft // equals with setCompoundDrawablesWithIntrinsicBounds


and



android:drawablePadding // this used to control the padding between the text and drawable


.

stackoverflow.comm

[android help] How to send data from an Android application to a server?


I'm developping an online Chess game in Android. The first player uses the app and the second a webpage in html.


What i want to do is to send the text with the information of every move each player makes in his turns. All the processing and validation parts of the game will be done in the Android application. The second player just receives the text, parses it into html code and then send a very similar text to the application in order to receive the authorisation of the move.


I'm really trying to spend the least possible of internet resources.


I've been searching what's my best option in order to send the messages with Android, but since I'm not very experienced with it, I don't know what to do.


I found these possibilities for sending the messages:


I have never used any of those technologies, but I would like to know which one could be the best for starting to make a deeper research of.


As you can see a chess game doesn't need a great amount of messaging since I have to send and receive a single message per move and per the authorisation of it by the chess engine in the Android application.


If you know a better solution or links with an example of the technology I should use, I would be very grateful.



.

stackoverflow.comm

[android help] How to show second fragment from first fragment with in a single activity


I am developing a simple android app only for tablets and using android 4.0. My application have the main screen like as follow:


enter image description here


Oncreate() of Main Activity I am adding Fragment A in the main.xml using following code:



FragmentTransaction ft = getFragmentManager().beginTransaction();
Fragment imageFragment = new ImageFragment();
ft.replace(R.id.fragment_container, imageFragment);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.addToBackStack(null);
ft.commit();


This fragment A just have only a Image view which is clickable. Now I want that when user click on Image view then another fragment (Fragment B) should call and it replace the image view. The Fragment B have a VideoView which play the video.


So My second screen should be like as follow:


enter image description here


My problem is I am not gettting "How to call second fragment from the first one with in main screen activity?"


I can use different activities but I do not want to do so and just want to run this using fragments.


Please guide me.



.

stackoverflow.comm

[android help] Android - Grabbing an image from a URL and displaying it in an ImageView with an AsyncTask

Android - Grabbing an image from a URL and displaying it in an ImageView with an AsyncTask - Stack Overflow




















I'm trying to get the app to show an image from a URL, im fairly certain the issue is with the AsyncTask but I've returned to this code several times over the past week and I still cant see where I'm going wrong.


The Internet permission is set and I am getting no LogCat



ImageView eventImage2;
eventImage2 = (ImageView) findViewById(R.id.eventImage2);

new imageupdate().execute();

public class imageupdate extends AsyncTask {

@Override
protected Bitmap doInBackground(Bitmap... url) {

URL url1;

try {
url1 = new URL("http://masterzangetsu.eu/Apps/NowIGetYou/banner.png");
HttpURLConnection connection = (HttpURLConnection) url1.openConnection();

Bitmap result = null;

InputStream is = connection.getInputStream();
Bitmap img = BitmapFactory.decodeStream(is);

img = result;

} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

return img;
}

protected void onPreExecute(String result) {

}

protected void onPostExecute(Bitmap result) {
super.onPostExecute(result);

eventImage2.setImageBitmap(result);
}
}




























Change this



Bitmap result = null;

InputStream is = connection.getInputStream();
Bitmap img = BitmapFactory.decodeStream(is);


img = result;


to



Bitmap img = null;

InputStream is = connection.getInputStream();
Bitmap img = BitmapFactory.decodeStream(is);


result = img;


and return result in doInBackground(). You have them switched around so 'img' will be null no matter what happens.


Also, you can't use Toast in doInBackground() as this method isn't run on the UI thread. You will need to make that a Log or put your Toast in onPostExecute() or onProgressUpdate(). These are the things I see. If you are still having problems then you need to be a little more clear on what specifically. You will need to debug and use breakpoints to see what isn't being returned that should be and pinpoint a little more what the problem is




















default







.

stackoverflow.comm

[android help] How to change Pin Number using sharedpreferences in Android?


I'm having implement android demo for application pin using shared preferences which i enter pin and confirm the pin.The problem is that when I am accessing this values, it is not returning updated values, it gives me NullPointerException.


String strGetPin;



public final String pref_filename = "settings";
String myPassword;
static SharedPreferences shaedPref;
public static String strdataReturned = "";


public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_list);
activity=this;


edtxt_EnterPin =(EditText)findViewById(R.id.edtxt_Pin);
edtxt_NewPin =(EditText)findViewById(R.id.edtxt_NewPin);
edtxt_ConfirmPin=(EditText)findViewById(R.id.edtxt_ConfirmPin);
shaedPref = getSharedPreferences(pref_filename, 0);
strdataReturned = shaedPref.getString("user", "");

if (strdataReturned.equals(""))
{
SharedPreferences.Editor editor = shaedPref.edit();
editor.putString("user", "1234"); // newData is new pass,passwordKey is key
editor.commit();
}




btnChangePin=(Button)findViewById(R.id.btn_ChangePin);
btnChangePin.setOnClickListener(new OnClickListener()
{

@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
myDialog=new Dialog(Settings_Activity.this);
myDialog.setContentView(R.layout.pin_change);
myDialog.setTitle("Application PIN Change");
myDialog.setCancelable(false);





//Button For Change Pin save
Button btnChange=(Button) myDialog.findViewById(R.id.btn_Save);
btnChange.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub


String stringData = edtxt_EnterPin.getText().toString().trim();
strdataReturned = shaedPref.getString("user", ""); // key/def message

// if stored password is equal to entered password
if (strdataReturned.equals(stringData))

{
String newData = edtxt_NewPin.getText().toString().trim();
SharedPreferences.Editor editor = shaedPref.edit();
editor.putString("user", newData); // newData is new pass, passwordKey is key
editor.commit();


Toast.makeText(getApplicationContext(),"PIN Change successfully", Toast.LENGTH_LONG).show();
edtxt_EnterPin.setText("");
edtxt_NewPin.setText("");
}

else

{
Toast.makeText(getApplicationContext(), "Wrong Pin!",Toast.LENGTH_LONG).show();
edtxt_EnterPin.setText("");
edtxt_NewPin.setText("");
}




}
});



Button btnCancel=(Button) myDialog.findViewById(R.id.btn_Cancel);
btnCancel.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
myDialog.dismiss();
}
});

myDialog.show();



}
});


}



.

stackoverflow.comm

[android help] how to fetch the area location on the google map using longitutte and latitude in android?


Code show location on Google Maps when you have longitude and latitude



Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("geo:0,0?q=" + latitude + "," + longitude));
startActivity(intent);


Fetch area location : For example: NewYork City...



try {
Geocoder gCoder = new Geocoder(getApplicationContext());
ArrayList
addresses = (ArrayList
) gCoder
.getFromLocation(latitude, longitude, 1);
if (addresses != null && addresses.size() > 0) {

Log.d(addresses.get(0)
.getThoroughfare()
+ " "
+ addresses.get(0).getSubAdminArea()
+ " "
+ addresses.get(0).getAdminArea()
+ ", "
+ addresses.get(0).getCountryName());
}
} catch (Exception e) {
// TODO: handle exception
}


.

stackoverflow.comm

[android help] initLoader() and onCreateOptionsMenu() threading issue


I am fetching some data from SQLite in a Fragment using a CursorLoader. The initLoader() for this is executed in onActivityCreated()...



public class MyFragment extends Fragment implements LoaderCallbacks
{
MenuItem menuItemOne;

@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
getLoaderManager().initLoader(0, null, this);
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
{
inflater.inflate(R.menu.myMenu, menu);
menuItemOne = menu.findItem(R.id.menuItemOne);
}

@Override
public void onLoadFinished(Loader loader, Cursor cursor)
{
menuItemOne.doSomething();
}
}


The above code is simplified for ease of reading. Here is my problem...


  • On a Nexus S, there is no problem.

  • On a Nexus 7, a null pointer arises in onLoadFinished. menuItemOne is null here.

The Nexus S is using Android 4.1.2 and the Nexus 7 is using Android 4.2.2.


  • Should I be running initLoader() elsewhere?

  • Do you think there is a bug/difference in the Android versions?


.

stackoverflow.comm

[android help] How to disable button in another activity?


I have a game activity and when it ends it goes to main menu and now I need to disable the button which starts the game that just ended. Let's call my game class classGame and my menu classMenu. I tried:


in my classGame:



classMenu obj = new classMenu();


And then in the same class when the time is right I call:



obj.myButtonToBeDisabled.setEnabled(false);


But I get stactOverflow errors on line where I created my obj as soon my menu activity starts. How to do this?


EDIT: I've also tried this in my gameClass:



public void disableButton(){
button.setEnabled(false);
}


and then calling it:



obj.disableButton


But the same error.


LogCat:



04-06 16:30:48.709: I/dalvikvm(25015): threadid=1: stack overflow on call to Ljava/lang/VMThread;.currentThread:L
04-06 16:30:48.709: I/dalvikvm(25015): method requires 0+20+0=20 bytes, fp is 0x4214d300 (0 left)
04-06 16:30:48.709: I/dalvikvm(25015): expanding stack end (0x4214d300 to 0x4214d000)
04-06 16:30:48.769: I/dalvikvm(25015): Shrank stack (to 0x4214d300, curFrame is 0x4214fcb0)
04-06 16:30:48.899: D/AndroidRuntime(25015): Shutting down VM
04-06 16:30:48.899: W/dalvikvm(25015): threadid=1: thread exiting with uncaught exception (group=0x40018560)
04-06 16:30:49.369: D/dalvikvm(25015): GC_CONCURRENT freed 325K, 50% free 2850K/5639K, external 0K/0K, paused 5ms+24ms
04-06 16:30:49.459: E/AndroidRuntime(25015): FATAL EXCEPTION: main
04-06 16:30:49.459: E/AndroidRuntime(25015): java.lang.StackOverflowError
04-06 16:30:49.459: E/AndroidRuntime(25015): at java.lang.Thread.currentThread(Thread.)
04-06 16:30:49.459: E/AndroidRuntime(25015): at java.lang.ThreadLocal.get(ThreadLocal.java:59)
04-06 16:30:49.459: E/AndroidRuntime(25015): at android.os.Looper.myLooper(Looper.)
04-06 16:30:49.459: E/AndroidRuntime(25015): at android.os.Handler.(Handler.)
04-06 16:30:49.459: E/AndroidRuntime(25015): at android.app.Activity.(Activity.)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:17)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Izbor.(Izbor.java:19)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.androidaplikacije.toplo_hladno.Asocijacije.(Asocijacije.java:32)
04-06 16:30:49.459: E/AndroidRuntime(25015): at rs.android
04-06 16:30:49.659: D/dalvikvm(25015): GC_CONCURRENT freed 522K, 51% free 2899K/5895K, external 0K/0K, paused 7ms+5ms


Asocijacije is my gameClass, and Izbor in my menuClass.



.

stackoverflow.comm

[android help] how to return to previous fragment activity

android - how to return to previous fragment activity - Stack Overflow



















Three fragment activities: MainFragmentActivity, Reports and ReportsType.


Reports is calling ReportsType.


There is a back button in ReportsType to go back with the following code:



public void goBackReport(View v)
{
finish(); // why MainFragmentActivity.java is called after finish()?
}


But its always returning to MainFragmentActivity.java. But it should be Reports.java.


























Try this..



Intent i=new Intent(this,MainFragmentActivity.class)
startActivity(i);
finish();

Intent i=new Intent(this,Reports.class)
startActivity(i);
finish();

Intent i=new Intent(this,ReportsType.class)
startActivity(i);
finish();


When you call new Activity write finish() in last























There's no concept of calling finish() on Fragment. Instead, you should keep stack of fragments when performing transactions. For example:



ft.addToBackStack(null); // ft is FragmentTransaction


So, when you press back-key, the current activity (which holds multiple fragments) will load previous fragment rather than finishing itself.




















default






.

stackoverflow.comm

[android help] Seekbar want to save progress

android - Seekbar want to save progress - Stack Overflow



















I am using seek bar i want to save changes made by user in seekbar & should be shown next time whenever he will open app . My code is



@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
start=-10; //you need to give starting value of SeekBar
end=10; //you need to give end value of SeekBar
start_pos=5; //you need to give starting position value of SeekBar

start_position=(int) (((start_pos-start)/(end-start))*100);
discrete=start_pos;
SeekBar seek=(SeekBar) findViewById(R.id.seekBar1);
seek.setProgress(start_position);
seek.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){

public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
Toast.makeText(getBaseContext(), "discrete = "+String.valueOf(discrete), Toast.LENGTH_SHORT).show();
}
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub

}
public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {
// TODO Auto-generated method stub
// To convert it as discrete value
float temp=progress;
float dis=end-start;
discrete=(start+((temp/100)*dis));

}
});
}
}

























Save seekbar progress to shared preference in onPause and set seekbar progress from shared preference in onResume




















default






.

stackoverflow.comm

[android help] Why doesn't Android Facebook interface work with Fragments?


As far as I could determine, the Facebook auth API does not support Fragments. Specifically, the onComplete() callback from the Facebook authorize() call works with Activities, but not with Fragments.


So I put together a simple workaround for Fragments. The solution depends on the fact that onActivityResult() is also called in the parent Activity when the authorize() call completes, so you can use it to set up a separate callback mechanism for the Fragment.


First, set up a variable in the parent Activity to carry the target Fragment's name, say



TargetFragment mTargetFragment;


You can initialize it when the Fragment is first instantiated like this:



@Override
public void onAttachFragment(Fragment fragment) {
super.onAttachFragment(fragment);

String fragmentSimpleName = fragment.getClass().getSimpleName();

if (fragmentSimpleName.equals("TargetFragment"))
mTargetFragment = (TargetFragment)fragment;
}


Then add a couple of lines to the onActivityResult() function:



@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (mTargetFragment != null)
mTargetFragment.myCallBack(requestCode, resultCode, data);
}


Now you can just mimic the code you would ordinarily put in the onComplete() callback in the new myCallBack() function:



public void myCallBack(int requestCode, int resultCode, Intent data) {
mFacebook.authorizeCallback(requestCode, resultCode, data);

// other code from your onComplete() function ...
}


I hope this can help someone else. Cheers!



.

stackoverflow.comm

[android help] FileNotFound Exception on Accesing PHP file in Android

httpclient - FileNotFound Exception on Accesing PHP file in Android - Stack Overflow



















I am trying on Client/Server side application in android. I have a php file which simply get or post data. On Android I have an activity which get and post data from server file. I hav problem in accessing that file which is located on c://xampp/htdocs/Project/server.php and in android I have these lines of code:



URL url = new URL("http://192.178.10.54/xampp/htdocs/Project1/server.php");
URLConnection connection = url.openConnection();


But when I run my app these lines of exception occurres :



04-09 16:18:21.484: W/System.err(7752):java.io.FileNotFoundException: http://192.178.10.54/xampp/htdocs/Project1/server.php
04-09 16:18:21.664: W/System.err(7752): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:177)
04-09 16:18:21.664: W/System.err(7752): at com.android.ServerInterface.executeHttpRequest(ServerInterface.java:111)
04-09 16:18:21.664: W/System.err(7752): at com.android.ServerInterface.getAnimalList(ServerInterface.java:60)
04-09 16:18:21.664: W/System.err(7752): at com.android.AndroidListClient$GetListTask.doInBackground(AndroidListClient.java:106)
04-09 16:18:21.664: W/System.err(7752): at com.android.AndroidListClient$GetListTask.doInBackground(AndroidListClient.java:1)





















default






.

stackoverflow.comm

[android help] how to return to previous fragment activity

android - how to return to previous fragment activity - Stack Overflow



















Three fragment activities: MainFragmentActivity, Reports and ReportsType.


Reports is calling ReportsType.


There is a back button in ReportsType to go back with the following code:



public void goBackReport(View v)
{
finish(); // why MainFragmentActivity.java is called after finish()?
}


But its always returning to MainFragmentActivity.java. But it should be Reports.java.


























Try this..



Intent i=new Intent(this,MainFragmentActivity.class)
startActivity(i);
finish();

Intent i=new Intent(this,Reports.class)
startActivity(i);
finish();

Intent i=new Intent(this,ReportsType.class)
startActivity(i);
finish();


When you call new Activity write finish() in last























There's no concept of calling finish() on Fragment. Instead, you should keep stack of fragments when performing transactions. For example:



ft.addToBackStack(null); // ft is FragmentTransaction


So, when you press back-key, the current activity (which holds multiple fragments) will load previous fragment rather than finishing itself.




















default






.

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