Monday, April 29, 2013

[General] Music to sd card


Agree with above. I would also recommend putting the music in a directory called "Music," if there isn't one already on the SD card. This is the typical default directory that various music players will look for. Once you pop that SD card back in, most music players will scan the directory and show your music files in your library, but sometimes you have to tell the music player where to look, and sometimes you have to tell the music player to re-scan the directories for added media. Which music player are you using?



.

forum.xda-developers.com

[android help] Change date displayed in button to DDth MMMM YY but keep values as DD/MM


I am using a DatePicker so that the user can select a date and find out the sunrise and sunset times for that particular date. The webservice I am using requires the date to be snet in the following format dd/MM but I would like the button to show the date in the format DDth MMMM YYYY e.g 21st March 2013


Any advice on how I should I go about doing this?


Code below as requested:



public class SunriseSunset extends Activity implements OnClickListener {

public Button getLocation;
public Button setLocationJapan;
public TextView LongCoord;
public TextView LatCoord;
public double longitude;
public double latitude;
public LocationManager lm;
public Spinner Locationspinner;
public DateDialogFragment frag;
public Button date;
public Calendar now;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sunrisesunset);

//Date stuff
now = Calendar.getInstance();
date = (Button)findViewById(R.id.date_button);
date.setText(String.valueOf(now.get(Calendar.DAY_OF_MONTH)+1)+"-"+String.valueOf(now.get(Calendar.MONTH))+"-"+String.valueOf(now.get(Calendar.YEAR)));
date.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
showDialog();
}
});

}
// More date stuff
public void showDialog() {
FragmentTransaction ft = getFragmentManager().beginTransaction(); //get the fragment
frag = DateDialogFragment.newInstance(this, new DateDialogFragmentListener(){
public void updateChangedDate(int year, int month, int day){
date.setText(String.valueOf(day)+"-"+String.valueOf(month+1)+"-"+String.valueOf(year));
now.set(year, month, day);
}
}, now);

frag.show(ft, "DateDialogFragment");

}

public interface DateDialogFragmentListener{
//this interface is a listener between the Date Dialog fragment and the activity to update the buttons date
public void updateChangedDate(int year, int month, int day);
}

public void addListenerOnSpinnerItemSelection() {
Locationspinner = (Spinner) findViewById(R.id.Locationspinner);
Locationspinner
.setOnItemSelectedListener(new CustomOnItemSelectedListener(
this));
}

private class LongRunningGetIO extends AsyncTask {

protected String getASCIIContentFromEntity(HttpEntity entity)
throws IllegalStateException, IOException {
InputStream in = entity.getContent();
StringBuffer out = new StringBuffer();
int n = 1;
while (n > 0) {
byte[] b = new byte[4096];
n = in.read(b);
if (n > 0)
out.append(new String(b, 0, n));
}
return out.toString();
}

@Override
protected String doInBackground(Void... params) {
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();

// Finds todays date and adds that into the URL
SimpleDateFormat df = new SimpleDateFormat("dd/MM");
String formattedDate = df.format(now.getTime());

String finalURL = "http://www.earthtools.org/sun/"
+ LatCoord.getText().toString().trim() + "/"
+ LongCoord.getText().toString().trim() + "/"
+ formattedDate + "/99/0";
HttpGet httpGet = new HttpGet(finalURL);
String text = null;

try {
HttpResponse response = httpClient.execute(httpGet,
localContext);
HttpEntity entity = response.getEntity();
text = getASCIIContentFromEntity(entity);
} catch (Exception e) {
return e.getLocalizedMessage();
}
return text;
}

protected void onPostExecute(String results) {
if (results != null) {
try {

DocumentBuilderFactory dbFactory = DocumentBuilderFactory
.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
InputSource s = new InputSource(new StringReader(results));
Document doc = dBuilder.parse(s);
doc.getDocumentElement().normalize();
TextView tvSunrise = (TextView) findViewById(R.id.Sunrise);
TextView tvSunset = (TextView) findViewById(R.id.Sunset);
tvSunrise.setText(doc.getElementsByTagName("sunrise").item(0).getTextContent());
tvSunset.setText(doc.getElementsByTagName("sunset").item(0).getTextContent());
} catch (Exception e) {
e.printStackTrace();
}
}
Button b = (Button) findViewById(R.id.CalculateSunriseSunset);
b.setClickable(true);
}
}

class MyLocationListener implements LocationListener {
@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
}

@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
}
}

}


DateDialogFragment:



import java.util.Calendar;

import richgrundy.learnphotography.SunriseSunset.DateDialogFragmentListener;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Context;
import android.os.Bundle;
import android.widget.DatePicker;

public class DateDialogFragment extends DialogFragment {

public static String TAG = "DateDialogFragment";
static Context mContext; //I guess hold the context that called it. Needed when making a DatePickerDialog. I guess its needed when conncting the fragment with the context
static int mYear;
static int mMonth;
static int mDay;
static DateDialogFragmentListener mListener;

public static DateDialogFragment newInstance(Context context, DateDialogFragmentListener listener, Calendar now) {
DateDialogFragment dialog = new DateDialogFragment();
mContext = context;
mListener = listener;
mYear = now.get(Calendar.YEAR);
mMonth = now.get(Calendar.MONTH);
mDay = now.get(Calendar.DAY_OF_MONTH);
return dialog;
}


public Dialog onCreateDialog(Bundle savedInstanceState) {
return new DatePickerDialog(mContext, mDateSetListener, mYear, mMonth, mDay);
}


private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {

@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;

mListener.updateChangedDate(year, monthOfYear, dayOfMonth);
}
};

}


Your help would be greatly appreciated.


Please ask questions for clarification if need =)


----------------UPDATE-------------------------


I'm getting there, updated code now looks like this:



public void showDialog() {
FragmentTransaction ft = getFragmentManager().beginTransaction(); //get the fragment
frag = DateDialogFragment.newInstance(this, new DateDialogFragmentListener(){

public void updateChangedDate(int year, int month, int day){
DateFormat format = new SimpleDateFormat("DD MM yyyy"); // could be created elsewhere
now.set(year, month, day);
date.setText(format.format(now.getTime()));
date.setText(String.valueOf(day)+"-"+String.valueOf(month+1)+"-"+String.valueOf(year));
now.set(year, month, day);
}
}, now);

frag.show(ft, "DateDialogFragment"); }


.

stackoverflow.comm

[General] Charge Phone Broken Charging Port?


Is there a way to charge my phone with a broken charging port?

Will this work?

--

Also, is there any way to buy a new battery cover for my phone? Motorola Triumph



.

forum.xda-developers.com

[android help] Selected Tab in TabHost not come to center


I am having a TabHost that have 5 tabs. I want to center the tab that is selected. So far i tried will give in following.


Declarations in onCreate:



scale = getApplicationContext().getResources().getDisplayMetrics().density;

screenWidth = getWindowManager().getDefaultDisplay().getWidth();

for (int i = 0; i < mTabHost.getTabWidget().getTabCount(); i++)
{
mTabHost.getTabWidget().getChildTabViewAt(i).getLayoutParams().width = (int) tabWidth;
}


This is onTabChanged method:



@Override
public void onTabChanged(String tabId) {
int position = mTabHost.getCurrentTab();
mViewPager.setCurrentItem(position);
mTabHost.getTabWidget().getChildAt(position).setBackgroundResource(R.drawable.tab_background_selector);
SearchIndexActivity searchIndexActivity = new SearchIndexActivity();
Calculation calculation = searchIndexActivity.new Calculation();
calculation.TabCalculation(position);
mHorizontalScrollView.scrollTo(offset, 0);
}


This is the class that makes the calculation for centering the tab.



public class Calculation
{
public void TabCalculation(int position)
{
tabWidth = (int) (150 * scale + 0.5f);

nrOfShownCompleteTabs = ((int) (Math.floor(screenWidth
/ tabWidth) - 1) / 2) * 2;
remainingSpace = (int) ((screenWidth - tabWidth - (tabWidth * nrOfShownCompleteTabs)) / 2);
Log.e("postion in TabCalculation", String.valueOf(position));
//a = (int) (mTabHost.getCurrentTab() * tabWidth);
a = (int) (position * tabWidth);
b = (int) ((int) (nrOfShownCompleteTabs / 2) * tabWidth);
Log.e("a value", String.valueOf(a));
Log.e("b value", String.valueOf(b));
Log.e("tabWidth", String.valueOf(tabWidth));
offset = (a - b) - remainingSpace;
Log.e("offset", String.valueOf(offset));
}


This is all i have done. But tab is not come center. It just come to first tab. Current tab is not coming in center of the screen.


Where am going wrong. Anyone can help me to find out.



.

stackoverflow.comm

[android help] LocalStorage store not persisting on Android phone when app stops using Sencha Touch 2.2 and Phonegap


This is working fine in my browser but when I install the app on my phone and use it ... it looks fine UNTIL I force it to stop and reopen the app and then all my records are gone.


Im using 2.2 and Phonegap.... any help would be VERY appreciated. Here is my store:



Ext.define('MyApp.store.Presentations', {
extend: 'Ext.data.Store',

config: {
model: 'MyApp.model.Presentations',
sorter: 'title',
grouper: function (record) {
var upperCased = record.get('title')[0].toUpperCase();
return upperCased; //First letter of the title - how we GROUP these
},
autoLoad: true,
proxy: {
type: 'localstorage',
id: 'presentations'
}
}
});


I save like this:



var newPresentation = { title: prezTitle, content: '' };
Ext.getStore('Presentations').add(newPresentation);
var newRecord = Ext.getStore('Presentations').sync();


.

stackoverflow.comm

[General] Very Under-qualified


I'm not sure if this is the right place for this thread, but oh well.

So I thought I was ready for rooting, and it turns out that it is way over my head. A month back, I tried rooting my Galaxy Nexus, and I think I ruined it beyond repair. When I turn the phone on, the Google logo displays and it doesn't get any further into the booting process.

Since then, I found another on Craigslist, but I've been very hesitant about trying the rooting process again. Just thought I'd share my story, maybe someone can help me out next time I try.



.

forum.xda-developers.com

[android help] action bar item onoptionitemselected


I'm using action bar in my application and I want when the user clicks a button, the item in action bar should change text.


This is my code for onOptionsItemSelected()



public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_refresh:
Toast.makeText(this, "Menu Item 1 selected", Toast.LENGTH_SHORT)
.show();
finish();
break;
case R.id.lg:

Toast.makeText(getBaseContext(), "ma", Toast.LENGTH_SHORT).show();
break;

case R.id.French:

Toast.makeText(getBaseContext(), "zaki", Toast.LENGTH_SHORT).show();

break;
case R.id.nerlandais:
Toast.makeText(getBaseContext(), "brahim", Toast.LENGTH_SHORT)
.show();

}

return true;
}


What must I do to add to change the item title from another item.


Example: When I click in French item I want to change nerlandais item title.



.

stackoverflow.comm

[General] Firefox and Chrome - change focus to New Tab?


How do you force Firefox and Chrome (this is two questions) to change focus to a new tab when you open a link in a new tab? I'm looking for same behavior like in the windows versions, but cannot find any settings to do it.

I tried the Dolphin browser and I see it does that already, without having to set any configuration.



.

forum.xda-developers.com

[android help] Where the "myfilename.txt" in android phone being stored?


I compiled this project in Eclipse.


It is an android app.


I run it in my samsung mobile. But I'm still wondering where the "myfilename.txt" is stored in the android phone.



.

stackoverflow.comm

[android help] How to increase icon size of actionButton in SherlockActionBar?


To define the actionButton and set its icon, I would:




android:id="@+id/m_login"
android:enabled="true"
android:showAsAction="always"
android:icon="@drawable/login"/>




The resulted icon(drawable/ldpi) looks very small by default: (Any way to increase the size?)


enter image description here


Here's the icon:


enter image description here



.

stackoverflow.comm

[General] Titanium Back froze my phone


I have a nexus phone that is unlocked and rooted. I installed titanium backup and backed everything up. I was trying to set a widget on the home page to freeze and defrost apps and by mistake hit freeze all apps. I stopped it as fast as I could and was able to defrost all apps but not when to to the phone on the screen is dark and there is a box that says "unfortunately. Phone has stooped" I have pulled battery and it still does it.



.

forum.xda-developers.com

[General] Google Music general questions and issues.


I'm just going to name a bunch of issues that keep me from using it. I'd like to use it though since it has more settings and a lock screen controller.

When I'm playing a song, and the song is on-screen, when I turn the screen to change viewing positions the cover art will go away and the timer will go to "--:--" and the only way to make it go back to normal is to either press thumbs up or down. Or, go to the next song. There is also like 3 other ways this can happen.

General problems with album art. Not showing, not showing correctly, disappearing (see above) etc.

The EQ animation in the song/album list will continue to play even when the music is paused.

I think a understated the first problem since I apparently can't think of any more. I don't know if I'm the only one who has this problem but I basically can't use the app because of this. Even without going that far, there isn't enough pros to use it over the stock player.

Does anyone else have this issue? I'm on the latest version and it happened on a much older version as well, before I updated.



.

forum.xda-developers.com

[android help] sqlite statement is ok, right?


When I use the sentence below works fine!



this.getWritableDatabase().execSQL(
"UPDATE table SET assistance =assistance + 1 WHERE alum ='Saul'");


But when I tried doing it passing a variable like this:



this.getWritableDatabase().execSQL(
"UPDATE table SET assistance =assistance + 1 WHERE alum ='"+names[i]+"'");


Don't work at all : ( it does not hive me any errors but my assistance field don't goes up by 1, by the way the statement above is inside a loop, that's because I want to update all the assistance fields that match whit my names (names[i]). Sorry for my English and please help


//edit:


so here is the method event from one activity that tigger the helper method


public void pasar(View args){



choosennames= new String[500];
for(int i=0;i

TextView viewName= (TextView) findViewById(i);
//an array names
names.add(viewName);


}

for( j = 0;j obj= name.get(j);



for(k=0;k if(obj.getId()==num.get(k))
{

choosennames[z]=obj.getText().toString();

z++;
}
}
}

z=0;
helper.open();
howmany=num.size();
helper.mod(choosennames, howmany);
helper.close();
choosennames=null;


Iterator it = numeros.iterator(); //se crea el iterador it para el array
while(it.hasNext())
System.out.println(it.next());




Intent inten = new Intent(this, MainLista.class);
this.finish();

Toast toast1 =
Toast.makeText(getApplicationContext(),
"Pase de lista exitoso : )", Toast.LENGTH_SHORT);

toast1.show();
startActivity(inten);





}


And finally this is my method "mod" inside the helpers class:


public void mod(String []names,int howmany){



for(int i=0;i System.out.println("exectSQL:"+names[i]);

System.out.println("UPDATE alumnos SET asistencia =asistencia + 1 WHERE alumno ='"+names[i]+"'");

this.getWritableDatabase().execSQL(
"UPDATE alumnos SET asistencia =asistencia + 1 WHERE alumno ='"+names[i]+"'");



}




}


.

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