Friday, May 3, 2013

[General] iOS to Android - things I miss


Switched over from an iPhone to my Note II not too long ago and am really enjoying it but there are a couple things about iOS that I'm starting to wish android had as well. The first being better music capabilities. A quick double tap of the home button with the iphone brought up a simple player that tied in beautifully with the lockscreen (or multitask bar if your phone wasn't locked.) I can't seem to find anything for android that does this. There's also a jailbreak tweak for the iphone called Activator which basically let's you assign functions to anything. For example, I had the volume up button set to change tracks when long pressed. It was really handy when driving rather than having to take my eyes off the road and fumble with the phone to change tracks.

Thing number two: volume control. The volume buttons on the iphone control everything whereas the volume buttons on my phone control only the ringtone. I would like for all sounds to be linked together.

Anybody know of any root or non root apps that can do what I've mentioned? Thanks guys.



.

forum.xda-developers.com

[General] Can't activate Boost ZTE Warp Sequent!?!


I purchased a used Boost Mobile ZTE Warp

Sequent from a reputable seller on Ebay. Boost

tells me they can't activate it, the MEID isn't in

their system. This IS a Boost phone. It boots up

with the Boost logo, says Boost Mobile beneath

the signal strength indicator (which shows it

receiving a signal AND 3G). It has Call Balance,

Call Reboost, and Care Services in the

contacts, everything in the phone is set up for

Boost. Is Boost bending me over with no

reacharound because they want me to buy a

phone from them? I've been a Boost customer

for over 5 years. Is this how they reward loyalty?



.

forum.xda-developers.com

[General] Samsung Galaxy S - All Messages Randomly Delete


I went to send a text message today, and all of my conversations had been cleared. This has happened once before about a year ago and I eventually gave up trying to restore my messages. Has anyone ever heard of this happening/know how to prevent it? I'm thinking the message database is somehow getting corrupted which is why it's clearing out all of my conversations?

Please let me know if you have any suggestions!

I'm running 2.3.3 - my phone was rooted at some point but I'm guessing after an OS update I lost that capability. This happened before the OS update and now after.



.

forum.xda-developers.com

[android help] How to handle empty ListView in android?


Having a bit of trouble dealing with empty ListView in android. Here's what I've got:



public class MainActivity extends ListActivity {
...
refreshList();
...}


public void refreshAlbumList(){
albumList=control.listAlbums();

if (albumList.length!=0){
ArrayAdapter ap = new ArrayAdapter(this,android.R.layout.simple_list_item_1,albumList);
setListAdapter(ap);
}else{
//deal with empty list somehow, currently results in error
}
}


What I've tried is:



this.getListView().setEmptyView(findViewById(android.R.id.empty));


And then inserting a TextView with id empty into main_activity.xml But the result was that took over the screen and I couldn't see the list.


Current xml:



xmlns:tools="http://schemas.android.com/tools"
xmlns:android1="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".MainActivity" >

android1:id="@id/android:list"
android1:layout_width="match_parent"
android1:layout_height="wrap_content"
android1:layout_weight="1" >





.

stackoverflow.comm

[android help] Android webview cache force loading


This might be a very trivial question with android webviews, but I am not getting good and clear material online to understand the concept. I am trying to build a webview android app that connects to a server initailly, downloads the HTML/JS/CSS data to local cache (getCacheDir) and serves the content from there. Any server call from the webview goes out to the server and results are returned and interpretted. But the assets are loaded from the local webview cache. The next time app is launched, there is some logic that checks if the version of the downloadable assets have changed, and in that case new package is downloded and replaced in the cache. If ther is no change, the content is served from the cache.


Now what I have the following questions: is the webview cache same as application cache (set vai getCacheDir() ) as in webview we do



webview.getSettings.setAppCachePath(getCacheDir().getAbsolutePath(+"/cache");


can i force the webview to load from cache VS network (using LOAD_CACHE_ELSE_NETWORK and LOAD_DEFAULT)


I am a bit confused. Please clarify these concepts?



.

stackoverflow.comm

[android help] Wat is the best way to refresh a android's listview


I want to refresh the listView after an insert or delete in the database.. I search and i found notifyDataSetChanged () but i don't know how to use it..


I used AsyncTask to get the data from the server and insert it into the SQLite database. The problem is, the AsyncTask class is in a another file. So how can i access the adapter or the listview from the AsyncTask class?


Someone can explain how to do this? Even by a different way..


Here is my code...



public class devicesController extends SherlockFragment {

devicesDataSource deviceDS;
static devicesAdapter adapter;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
View view = inflater.inflate(R.layout.devices, container, false);

/// Set device's datasource
deviceDS = new devicesDataSource(getActivity());

/// Assign the listview from the xml layout
ListView lv1 = (ListView) view.findViewById(R.id.devicesList);

/// Getting all devices from the SQLite database
deviceDS.open();
List allDevices = null;
try {
allDevices = deviceDS.getAll();
} catch (ParseException e) {
e.printStackTrace();
Log.i("QUTAYBA", "ERROR showing data");
}


/// Set the results rows in a list adapter
adapter = new devicesAdapter(getActivity(), R.layout.devices_list, allDevices);
lv1.setAdapter(adapter);

return view;

}


.

stackoverflow.comm

[android help] Android Programming: Looping Voice Recognition


I'm looking to make a custom Android app to help out a physically disabled person. I need to heavily rely on voice recognition. The idea would be:


  1. the app (via voice recognition) accepts his speech

  2. the app parses his speech and executes his commands ("email dad", "text fred", "what time is it?", etc, plus other things I'll be adding to control his tv, lights, etc)

  3. after execution, the app waits for his next command (loop back to #1)

I have #1 & #2 working fine, but I can't figure out a good method for #3. I can't leave Google's voice recognition view running indefinitely because it could be hours before the next command. But the 'trigger' does have to be based on sound/voice. Has to be completely hands free.


Ideally, the app would just listen for a sound, and if that sound is above a certain pre-programmed decibel level, I'd start voice recognition. Is it possible to constantly loop just listening for a noise, then react if it's 'so' loud?


Any ideas?


Thanks



.

stackoverflow.comm

[android help] How to get crypto scheme UUID



MediaCrypto class can be used in conjunction with MediaCodec to decode encrypted media data. Crypto schemes are assigned 16 byte UUIDs, the method isCryptoSchemeSupported(UUID) can be used to query if a given scheme is supported on the device. http://developer.android.com/reference/android/media/MediaCrypto.html



But what is crypto scheme UUID and where can I get it? Seems like I've missed it.


Thanks in advance :)



.

stackoverflow.comm

[android help] Supporting Multiple Screens for hundreds of icons

android - Supporting Multiple Screens for hundreds of icons - Stack Overflow







Tell me more ×

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

















In my application I have to use hundreds of bitmap icons and we want to support multiple screen.


And through the documents at android developer, it seems that it is the only way to create these icons for different devices with different dpi.


If this is true, we will have a hard work, so I want to know if there is an alternative to avoid this?
















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










default






.

stackoverflow.comm

[android help] Call to Asynchronous Function


I am using parse.com as my backend service for my Android application. I wish to make separation between my activities and parse, for this purpose I have created service class witch will bridge activities and parse (backend). Most parse functions are asynchronous and I don't really know how to handle them. For example if I want to login with a user I will call the service object that should execute login with parse login function. So here is my code in the activity:



LoginService login = new LoginService("username", "password");
login.login();
//from here it is not correct
if(login.getLoginStatus() == 2) {
//user loggedin
}...


and my service code is:



public LoginSrvice(String userName, String pass)
{
this.userName = userName;
this.pass = pass;
}

public void loginUser()
{
ParseUser.logInInBackground(userName, pass, new LogInCallback()
{

@Override
public void done(ParseUser user, ParseException e) {
if (user != null) {
logedIn = 1;
} else {
logedIn = 2;
}
}
});
}

public int getLoginStatus()
{
return logedIn;
}


My question is how should I do it right? how can i keep both activities and services separated but still wait for the response in the activity till the service class will get the callback from parse. Thanks for the HELP in advance!



.

stackoverflow.comm

[android help] can not open files with openFileInput saved via openFileOutput



Thread thread = new Thread() {

@Override
public void run() {
try {
saveDataFromWeb();// here i write data into a file
} catch (Throwable e) {
AlertDialog.Builder builder = new AlertDialog.Builder(
findViewById(R.id.viewpager).getContext());
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
sw.toString();
builder.setMessage(sw.toString());
AlertDialog alert = builder.create();
alert.show();
}
}
};
if (CONDITION) {
thread.start();
parseData("ThisWeekDatabase"); // here I read the data from the
parseData("NextWeekDatabase");
}


I found the error. It is because the thread is not done with it's work (writing data from the web into files) when I try to read these files. Now I need a way to "wait" for the thread so it has finished writing the files when parseData(xyz) needs them.


also either the way I write the data into the file or the way I read the data from the files is wrong because I get one single long line when I read out of the files I have written in before instead of multiple short lines.


I get



div.lvsdrt {background-color:#e3f1ff; border-top:black 1px dotted;padding:0.1em;}div.lvwer{background-color:#f2f9ff;border-top:black 1px dotted;padding:0.1em;}div.nobreak {page-break-inside:avoid;}


instad of



div.lvsdrt {
background-color:#e3f1ff;
border-top:black 1px dotted;
padding:0.1em;
}
div.lvwer {
background-color:#f2f9ff;
border-top:black 1px dotted;
padding:0.1em;
}
div.nobreak {
page-break-inside:avoid;
}


.

stackoverflow.comm

[android help] how to access the drawable resources by name in android


You could do something like this.-



public static Drawable getDrawable(String name) {
Context context = YourApplication.getContext();
int resourceId = context.getResources().getIdentifier(name, "drawable", YourApplication.getContext().getPackageName());
return context.getResources().getDrawable(id);
}


In order to access the context from anywhere, you may extend Application class.-



public class YourApplication extends Application {

private static YourApplication instance;

public YourApplication() {
instance = this;
}

public static Context getContext() {
return instance;
}
}


And map it in your Manifest application tag



android:name=".YourApplication"
....


.

stackoverflow.comm

[android help] PhoneGap App with database


I'm new to this, and I am trying to build an app to be deployed with PhoneGap, to both Android and iOS. I am wondering how to link to a database which will store timetable data.


My question is how to include the database so it can be packaged with PhoneGap.


I have looked at the PhoneGap docs, and they don't really make sense to me as to how to set up/create the database



Update: This website shows some info on local storage, but when i put it in, hangs on the loading image.


Any further ideas?


http://www.aquim.com/web-article-237.html



.

stackoverflow.comm

[android help] Passing items to onPause() method


I know this is a basic question, but I'm pretty new to all of this. In the code below, I have this onPause method:



public void onPause(){
super.onPause();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
}


the input part of input.getWindowToken() doesn't resolve, I'm guessing because it's not defined/instantiated in the same scope? I think I'm using the right terminology... I'm not even positive I sohuld be trying to use an EditText object right here either, but it seems whatever I try to use won't resolve.


How do I pass something to my onPause() method, or any other method for that matter? Here's all of my code:



package com.example.test_project;

import java.util.Calendar;

import com.example.test_project.R.string;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TimePicker;

public class NewWorkout extends Activity {
/** Called when the activity is first created. */

private TextView mDateDisplay;
private Button mPickDate;
private int mYear;
private int mMonth;
private int mDay;

private TextView mTimeDisplay;
private Button mTimePicker1;
private int hour;
private int minute;
private String zone;

static final int DATE_DIALOG_ID = 0;
static final int TIME_DIALOG_ID = 99;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_workout);
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

// capture our View elements
mDateDisplay = (TextView) findViewById(R.id.dateOfWorkoutTextView);
mPickDate = (Button) findViewById(R.id.dateOfWorkoutButton);
mTimeDisplay = (TextView) findViewById(R.id.timeOfWorkoutTextView);
mTimePicker1 = (Button) findViewById(R.id.timeOfWorkoutButton);


// add a click listener to the button
mPickDate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
showDialog(DATE_DIALOG_ID);
}
});

// get the current date
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);

final Calendar t = Calendar.getInstance();
hour = t.get(Calendar.HOUR_OF_DAY);
minute = t.get(Calendar.MINUTE);

//set the current time into the textview



mTimePicker1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
showDialog(TIME_DIALOG_ID);
}
});

}

// updates the date in the TextView
private void updateDisplay() {
StringBuilder string1 = new StringBuilder()
// Month is 0 based so add 1
.append(mMonth + 1).append("-")
.append(mDay).append("-")
.append(mYear).append(" ");
mDateDisplay.setText(string1);
}

// the callback received when the user "sets" the date in the dialog
private DatePickerDialog.OnDateSetListener mDateSetListener =
new DatePickerDialog.OnDateSetListener() {

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

private TimePickerDialog.OnTimeSetListener timePickerListener =
new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view, int selectedHour, int selectedMinute) {
hour = selectedHour;
minute = selectedMinute;
updateTimeDisplay();
}
};

//set current time into textView
private void updateTimeDisplay() {
if(hour > 12){
hour -= 12;
zone = "PM";
}
else
zone = "AM";

if(minute >= 10){
mTimeDisplay.setText(new StringBuilder().append(hour)
.append(":").append(minute).append(" ").append(zone));
}
else
mTimeDisplay.setText(new StringBuilder().append(hour)
.append(":").append("0").append(minute).append(" ").append(zone));
}

@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
return new DatePickerDialog(this, mDateSetListener, mYear, mMonth,
mDay);
case TIME_DIALOG_ID:
return new TimePickerDialog(this, timePickerListener, hour, minute, false);
}
return null;
}



public void nameOfWorkout(View view){
AlertDialog.Builder nameOfWorkoutAlert = new AlertDialog.Builder(this);
nameOfWorkoutAlert.setTitle("Enter a Name for This Workout");

// Set an EditText view to get user input
final EditText input = new EditText(this);
nameOfWorkoutAlert.setView(input);
// Prepping the soft keyboard to open with the AlertDialog
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(input.getWindowToken(), 0);

nameOfWorkoutAlert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString();
TextView edit = (TextView) findViewById(R.id.nameOfWorkoutTextView);
edit.setText(value);
imm.toggleSoftInput(InputMethodManager.RESULT_HIDDEN, 0);
}
});

nameOfWorkoutAlert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
imm.toggleSoftInput(InputMethodManager.RESULT_HIDDEN, 0);
}
});
//alert.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
nameOfWorkoutAlert.show();

//Causing the soft keyboard to open with the AlertDialog
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}

public void onPause(){
super.onPause();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
}

public void typeOfWorkout(View view){
final String [] items=new String []{"Weight-lifting","Cardio","Mixture"};
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setTitle("Select Today's Workout type");

builder.setItems(items, new android.content.DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
TextView txt=(TextView)findViewById(R.id.typeOfWorkoutTextView);
txt.setText(items[which]);
}
});

builder.show();

}

}


Thanks for the help!



.

stackoverflow.comm

[android help] Closing Soft Keyboard on Home Button Press


So I have an app with a custom AlertDialog that has an Ok and Cancel button, and an EditText Object. When I click on the 'Name of Workout' button, the AlertDialog and the soft Keyboard open. At this point, with the AlertDialog open and the soft Keyboard displayed, if the user decides to hit the home key, the app closes, but the soft keyboard is still displayed. How would I close the soft Keyboard along with the entire app from this point? Here is my code:



package com.example.test_project;

import java.util.Calendar;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TimePicker;

public class NewWorkout extends Activity {
/** Called when the activity is first created. */

private TextView mDateDisplay;
private Button mPickDate;
private int mYear;
private int mMonth;
private int mDay;

private TextView mTimeDisplay;
private Button mTimePicker1;
private int hour;
private int minute;
private String zone;

static final int DATE_DIALOG_ID = 0;
static final int TIME_DIALOG_ID = 99;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_workout);
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

// capture our View elements
mDateDisplay = (TextView) findViewById(R.id.dateOfWorkoutTextView);
mPickDate = (Button) findViewById(R.id.dateOfWorkoutButton);
mTimeDisplay = (TextView) findViewById(R.id.timeOfWorkoutTextView);
mTimePicker1 = (Button) findViewById(R.id.timeOfWorkoutButton);


// add a click listener to the button
mPickDate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
showDialog(DATE_DIALOG_ID);
}
});

// get the current date
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);

final Calendar t = Calendar.getInstance();
hour = t.get(Calendar.HOUR_OF_DAY);
minute = t.get(Calendar.MINUTE);

//set the current time into the textview



mTimePicker1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
showDialog(TIME_DIALOG_ID);
}
});

}

// updates the date in the TextView
private void updateDisplay() {
StringBuilder string1 = new StringBuilder()
// Month is 0 based so add 1
.append(mMonth + 1).append("-")
.append(mDay).append("-")
.append(mYear).append(" ");
mDateDisplay.setText(string1);
}

// the callback received when the user "sets" the date in the dialog
private DatePickerDialog.OnDateSetListener mDateSetListener =
new DatePickerDialog.OnDateSetListener() {

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

private TimePickerDialog.OnTimeSetListener timePickerListener =
new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view, int selectedHour, int selectedMinute) {
hour = selectedHour;
minute = selectedMinute;
updateTimeDisplay();
}
};

//set current time into textView
private void updateTimeDisplay() {
if(hour > 12){
hour -= 12;
zone = "PM";
}
else
zone = "AM";

if(minute >= 10){
mTimeDisplay.setText(new StringBuilder().append(hour)
.append(":").append(minute).append(" ").append(zone));
}
else
mTimeDisplay.setText(new StringBuilder().append(hour)
.append(":").append("0").append(minute).append(" ").append(zone));
}

@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
return new DatePickerDialog(this, mDateSetListener, mYear, mMonth,
mDay);
case TIME_DIALOG_ID:
return new TimePickerDialog(this, timePickerListener, hour, minute, false);
}
return null;
}


public void nameOfWorkout(View view){
AlertDialog.Builder alert = new AlertDialog.Builder(this);

alert.setTitle("Enter a Name for This Workout");

// Set an EditText view to get user input
final EditText input = new EditText(this);
alert.setView(input);
// Prepping the soft keyboard to open with the AlertDialog
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(input.getWindowToken(), 0);

alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString();
TextView edit = (TextView) findViewById(R.id.nameOfWorkoutTextView);
edit.setText(value);
imm.toggleSoftInput(InputMethodManager.RESULT_HIDDEN, 0);
}
});

alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
imm.toggleSoftInput(InputMethodManager.RESULT_HIDDEN, 0);
}
});
//alert.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
alert.show();

//Causing the soft keyboard to open with the AlertDialog
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}

}


Thanks!


UPDATE:



package com.example.test_project;

import java.util.Calendar;

import com.example.test_project.R.string;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TimePicker;

public class NewWorkout extends Activity {
/** Called when the activity is first created. */

private TextView mDateDisplay;
private Button mPickDate;
private int mYear;
private int mMonth;
private int mDay;

private TextView mTimeDisplay;
private Button mTimePicker1;
private int hour;
private int minute;
private String zone;

static final int DATE_DIALOG_ID = 0;
static final int TIME_DIALOG_ID = 99;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_workout);
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

// capture our View elements
mDateDisplay = (TextView) findViewById(R.id.dateOfWorkoutTextView);
mPickDate = (Button) findViewById(R.id.dateOfWorkoutButton);
mTimeDisplay = (TextView) findViewById(R.id.timeOfWorkoutTextView);
mTimePicker1 = (Button) findViewById(R.id.timeOfWorkoutButton);


// add a click listener to the button
mPickDate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
showDialog(DATE_DIALOG_ID);
}
});

// get the current date
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);

final Calendar t = Calendar.getInstance();
hour = t.get(Calendar.HOUR_OF_DAY);
minute = t.get(Calendar.MINUTE);

//set the current time into the textview



mTimePicker1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
showDialog(TIME_DIALOG_ID);
}
});

}

// updates the date in the TextView
private void updateDisplay() {
StringBuilder string1 = new StringBuilder()
// Month is 0 based so add 1
.append(mMonth + 1).append("-")
.append(mDay).append("-")
.append(mYear).append(" ");
mDateDisplay.setText(string1);
}

// the callback received when the user "sets" the date in the dialog
private DatePickerDialog.OnDateSetListener mDateSetListener =
new DatePickerDialog.OnDateSetListener() {

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

private TimePickerDialog.OnTimeSetListener timePickerListener =
new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view, int selectedHour, int selectedMinute) {
hour = selectedHour;
minute = selectedMinute;
updateTimeDisplay();
}
};

//set current time into textView
private void updateTimeDisplay() {
if(hour > 12){
hour -= 12;
zone = "PM";
}
else
zone = "AM";

if(minute >= 10){
mTimeDisplay.setText(new StringBuilder().append(hour)
.append(":").append(minute).append(" ").append(zone));
}
else
mTimeDisplay.setText(new StringBuilder().append(hour)
.append(":").append("0").append(minute).append(" ").append(zone));
}

@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
return new DatePickerDialog(this, mDateSetListener, mYear, mMonth,
mDay);
case TIME_DIALOG_ID:
return new TimePickerDialog(this, timePickerListener, hour, minute, false);
}
return null;
}



public void nameOfWorkout(View view){
AlertDialog.Builder nameOfWorkoutAlert = new AlertDialog.Builder(this);
nameOfWorkoutAlert.setTitle("Enter a Name for This Workout");

// Set an EditText view to get user input
final EditText input = new EditText(this);
nameOfWorkoutAlert.setView(input);
// Prepping the soft keyboard to open with the AlertDialog
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(input.getWindowToken(), 0);

nameOfWorkoutAlert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString();
TextView edit = (TextView) findViewById(R.id.nameOfWorkoutTextView);
edit.setText(value);
imm.toggleSoftInput(InputMethodManager.RESULT_HIDDEN, 0);
}
});

nameOfWorkoutAlert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
imm.toggleSoftInput(InputMethodManager.RESULT_HIDDEN, 0);
}
});
//alert.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
nameOfWorkoutAlert.show();

//Causing the soft keyboard to open with the AlertDialog
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}

protected void onPause(){
super.onPause();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
}

public void typeOfWorkout(View view){
final String [] items=new String []{"Weight-lifting","Cardio","Mixture"};
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setTitle("Select Today's Workout type");

builder.setItems(items, new android.content.DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
TextView txt=(TextView)findViewById(R.id.typeOfWorkoutTextView);
txt.setText(items[which]);
}
});

builder.show();

}

}


.

stackoverflow.comm

[General] How to update CWM Galaxy S3 I747M With Rogers


Hi, I am very confused because when I try to install the Cyangenmod 10 ROM I get a Status 7 error. So I researched and found out I need to update CWM, But I have no clue on how to do this, I tried to use ROM Manager, but I could not find my device listed there. Am I allowed to flash CWM with a newer version, or will it brick my phone?



.

forum.xda-developers.com

[android help] Adding ActionBarSherlock in Eclipse Juno


From this web http://www.grokkingandroid.com/adding-actionbarsherlock-to-your-project/


Getting ActionBarSherlock and adding it to Eclipse


The first thing you have to do, is to download the library from actionbarsherlock.com. After this unzip/untar it. The download contains three folders: library, samples and website. The samples folder contains four sample projects to showcase what you can do and to show you how to do it. You should have a look at them. The website folder contains the code of the project website. The library folder finally contains ActionBarSherlock’s source code. Now go to Eclipse and add the ABS-library as an Android project. Do not use Eclipse’s import tool to import the ActionBarSherlock library – it would not work immediately and you would have to fix some settings. Instead use the project creation wizard of the Android Developer Tools.


Open File -> New -> Project -> Android Project From Existing Code.


Creating an Android project from existing source In the next screen select the folder, which Eclipse then uses to search for projects. If you select the ActionBarSherlock root folder, Eclipse suggests a list of projects to create. Leave the “library” project checked and uncheck all others:


Select the library project Click “Finish” to create the project.


Eclipse will now create a new project named “library”. I prefer a more useful name, so select the project called “library” and hit F2 to rename the project. I have renamed the project in Eclipse to “ActionBarSherlock”, so all following screens will refer to this name.


Adding the library to your project


Now that ABS is a library project you have to tell your own project to use it. I will use the project of my last post for this. Go to FragmentStarter’s project settings and switch to the Android tab.


If necessary scroll down until you see the Library panel. Click “Add”:


Adding libraries to an Android project In the next window all available library projects will be listed. Select ActionBarSherlock and click “Ok”.


Select ActionBarSherlock from the list of libraries When the window disappears the library should be listed in the library panel of the Android properties tab:


Check if the library has been added succesfully


Then appears an error: Jar mismatch! fix your dependencies, to solve it there is to copy the file android-support-v4.jar from your_project/libs and paste it on library/libs.


Before you can use ActionBarSherlock you have to extends your Activity like this: public class MainActivity extends SherlockActivity and change the theme in Manifest: android:theme="@style/Theme.Sherlock.Light.DarkActionBar"


This is the way to add ABS to your project. Hope it works for all



.

stackoverflow.comm

[General] Where is my Google play music on Note2


I have a Galaxy Note 2 and I use Google music. I had Google music manager on my laptop and I had a hard drive issue...it was fixed... and when I tried to reload Google music manager again....and it keeps saying "cannot connect check your internet connection" There are threads on this...it is a known problem with Google. So I want to take the music off my Galaxy Note2 and put it on my laptop. I cannot find the music on my phone... I've looked everywhere. I know it's on the phone because I can listen to them without internet connection, and I can see the space of the songs 1.6 gigs on the the space used in settings/application manager/Google play music. Where can I find the songs and why are they hidden...please if anyone can help me with this I will be very grateful... I'm going crazy trying to find them. I connect to the PC and use that file explorer and I have downloaded file managers as well. They are just not there....but they are. ARG. Thank you!



.

forum.xda-developers.com

[android help] ADT: Avoid duplicating code in package with dependency on another deployed package?


When I have e.g. a custom service and a custom activity in the same ADT project, then I can use this in the service, to start my activity:



Intent i = new Intent(context, MyCustomActivity.class);
startActivity(i);


However when I have the service and activity in separate projects, then I cannot do this since I do not have a direct reference to MyCustomActivity.class. This is problematic: I do not wish to include a JAR just to be able to fix that broken reference, since I assume this will increase the package size and create redundant data on the device (i.e. activity code is duplicated between the service and activity packages). So instead, I use this (perhaps there are other options?):



Intent i = new Intent("com.mypackage.myStringActionName");
startActivity(i); //is this a broadcast?


OR



Intent i = new Intent("com.mypackage.myStringActionName");
sendBroadcast(i);


...But I don't really like sending broadcasts when all I want is to direct the intent to a single activity to tell it to start.


So, what other ways are there to go about avoiding duplication (in ADT)? Or else a better way to send direct intents?



.

stackoverflow.comm

[android help] Android : Merge PDFs file using iText API not working


I am trying to merge pdf file by using iText API to merge two or more PDF documents into one.But in result i am getting merge pdf with 0 byte size.I post my code as shown below.I tried with iText.jar file also but give same 0 size pdf.


And got this :-"Could not find class 'com.itextpdf.text.pdf.PdfPrinterGraphics2D', referenced from method com.itextpdf.text.pdf.PdfContentByte.createPrinterGraphicsShapes". Still i am not getting any success.


Code:



public class ItextMerge {
public static void main() {
List list = new ArrayList();
try {
// Source pdfs
list.add(new FileInputStream(new File("mnt/sdcard/nocturia.pdf")));
list.add(new FileInputStream(new File("mnt/sdcard/Professional Android Application Development.pdf")));

// Resulting pdf
OutputStream out = new FileOutputStream(new File("mnt/sdcard/newmerge.pdf"));

doMerge(list, out);

} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}

/**
* Merge multiple pdf into one pdf
*
* @param list
* of pdf input stream
* @param outputStream
* output file output stream
* @throws DocumentException
* @throws IOException
*/
public static void doMerge(List list, OutputStream outputStream)
throws DocumentException, IOException {
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, outputStream);
document.open();
PdfContentByte cb = writer.getDirectContent();

for (InputStream in : list) {
PdfReader reader = new PdfReader(in);
for (int i = 1; i <= reader.getNumberOfPages(); i++) {
document.newPage();
//import the page from source pdf
PdfImportedPage page = writer.getImportedPage(reader, i);
//add the page to the destination pdf
// cb.addTemplate(page, 0, 0);
// cb.addTemplate(page, 0, 0);
}
}

outputStream.flush();
document.close();
outputStream.close();
}
}


Any idea?


Thank you



.

stackoverflow.comm

[General] Help identifying an icon on my phone


Hello
I am new to Android Ph's and I have a HTC One x with AT&T. I was able to identify all the icons on the top of the screen, excepting for one of them. It looks line 'N', in-between the Bluetooth and Ph-ringer icons. Can some one help me with that please. Thanks in advance.

I have attached an image for reference



.

forum.xda-developers.com

[android help] Blackberry 10 Android - Run As BlackBerry Android Launch fails


I have an Android/PhoneGap app and have verified with the online tool that it is compatible with the Runtime for Android apps.


On Windows 7 I have Eclipse Juno installed, with the new Blackberry Plugin. I have run the BlackBerry Deployment Setup Wizard.


I have successfully signed the app for BlackBerry World. I have Verified the App.


When I Run As BlackBerry Android Launch, I get the following error:


'Launching *' has encountered a problem. An internal error occurred during "Launching *".


The App runs well in the Android Emulator


Does anyone know what causes that error?



.

stackoverflow.comm

[android help] Blank Map Screen Open while using Google Maps Api v2


I am trying to use Google Maps Api V2 and following all the steps in Android Google Maps Article


But after all steps, code is executed on my glaxy young with android 2.36 but blank map screen is displayed


My main activity code is



protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.showmapactivity_layout);
FragmentManager myFragmentManager = getSupportFragmentManager();
SupportMapFragment mySupportMapFragment
= (SupportMapFragment)myFragmentManager.findFragmentById(R.id.map);
map = mySupportMapFragment.getMap();

//map = getFragmentManager().findFragmentById(R.id.map)).getMap();
Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
.title("Hamburg"));
Marker kiel = map.addMarker(new MarkerOptions()
.position(KIEL)
.title("Kiel")
.snippet("Kiel is cool")
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.ic_launcher)));

// Move the camera instantly to hamburg with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));

// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
}


Maifestfile code is




package="com.archifiles.pointpakistan"
android:versionCode="1"
android:versionName="1.0" >

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

android:name="com.archifiles.pointpakistan.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />

android:glEsVersion="0x00020000"
android:required="true" />








android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:name="com.archifiles.pointpakistan.SplashScreenActivity"
android:label="@string/app_name" >










android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDe_pk7x98rwq2GTkaaUUv0K0Yri3TRPUA" />

android:name="com.google.android.maps"
android:required="true" />




Layout file code



xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />




No log traces are available in log cat, Please help urgently



.

stackoverflow.comm

[General] Substitute for Samsung Kies?


Hi, I just wanted to see if there was a program that offered the same use as Samsung Kies? I tried downloading Kies about 3 days ago and I actually got some adware and a virus. So if anyone could link me to another program like it that is surely virus-free it would be great.



.

forum.xda-developers.com

[General] How to get contacts to show facebook pictures


Hey fellas,

So I linked my Facebook with my contacts and I'd say it gave about half my contacts pictures. I manually linked other Google contacts to Facebook contacts but those still fail to show pictures. Anyone have any idea of why?



.

forum.xda-developers.com

[android help] Different screen size layout

android - Different screen size layout - 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.

















Afternoon all:


After reading AndroidDev: Supporting Multiple Screens, I still wondering on multi-screen support.


As document says:


  • res/layout/my_layout.xml // layout for normal screen size ("default")

  • res/layout-small/my_layout.xml // layout for small screen size

  • res/layout-large/my_layout.xml // layout for large screen size

  • res/layout-xlarge/my_layout.xml // layout for extra large screen size

  • res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation

I currently have such device support for development:


  • 3.7" 480 x 800

  • 4.0" 480 x 800

  • 4.3" 480 x 800

  • 4.3" 540 x 960

  • 4.7" 720 x 1280

  • 5.0" 1080 x 1920

  • 7.0" 600 x 1024 (Tablet)

Can anybody help me to figure out what layout folder will my device matched ?


Thank you~


























You need to create different layout folder for Supporting Multiple Screens.


Please refer My answer.























Your devide will choose automatically depending on his characteristics. If your device has another screen he will choose res/layour automatically too.


You can check that ;) Supporting Different Screen Sizes




















default






.

stackoverflow.comm

[android help] SetAdapter for arrayadapter is crashing


My app keeps crashing whenever my setadapter function gets called and I have no idea why, can anyone help? The emulator that I am running just says that the app has stopped unexpectedly.


This is my Main



public class MainActivity extends Activity {

private ListView listView1;

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

Ride ride_data[] = new Ride[]
{
new Ride("LA Trip", "la man"),
new Ride("SD Trip", "sd man"),
new Ride("SF Trip", "sf man")
};

RideAdapter adapter = new RideAdapter(this,
R.layout.listview_item_row,ride_data);

listView1 = (ListView)findViewById(R.id.listView1);

View header = (View)getLayoutInflater().inflate(R.layout.listview_header_row, null);
listView1.addHeaderView(header);

listView1.setAdapter(adapter);

}

}


and this is my Adapter



public class RideAdapter extends ArrayAdapter{

Context context;
int layoutResourceId;
Ride data[] = null;

public RideAdapter(Context context, int layoutResourceId, Ride[] data)
{
super(context,layoutResourceId,data);
this.context = context;
this.layoutResourceId = layoutResourceId;
this.data = data;
}

@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View row = convertView;
RideHolder holder = null;

if(row == null)
{
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
row = inflater.inflate(layoutResourceId, parent, false);

holder = new RideHolder();
holder.rideName = (TextView)row.findViewById(R.id.txtRideName);
holder.personName = (TextView)row.findViewById(R.id.txtPersonName);

row.setTag(holder);
}
else
{
holder = (RideHolder)row.getTag();
}

Ride ride = data[position];
holder.rideName.setText(ride.rideName);
holder.personName.setText(ride.personName);

return row;

}

public static class RideHolder
{
TextView rideName;
TextView personName;
}
}


this is my ride class



public class Ride {
public String rideName;
public String personName;

public Ride()
{

}

public Ride(String rideName, String personName)
{
super();
this.rideName=rideName;
this.personName=personName;
}
}


and finally this is my list item view




android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="10dp"
>

android:id="@+id/txtRideName"
android:layout_width ="wrap_content"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
/>
android:id="@+id/txtPersonName"
android:layout_width ="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
/>




any help would be greatly appreciated!



.

stackoverflow.comm

[android help] Android: Setting Window Background on launched Activity


So I've read Romain Guy's blog post on setting the Window background and percieved performance, and am trying to emulate that. It is such a simple solution and not sure why I can't get this working, but the activity simply refuses to pick-up the directed background.


I have a ListView that onListItemClick launches a new Activity, one that takes 3-5 seconds to fully load. While the user is waiting, I'd like to draw a windowBackground so that they 'see' the activity before it is actually ready. Here's my code:


AndroidManifest snippet for the launched Activity:



android:name=".activity.EditorActivity"
android:screenOrientation="portrait"
android:windowBackground="@drawable/background_editor">


The XML layout for the EditorActivity:




android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/editor"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="Editor" />



And finally, the drawable being set in the Manifest, background_editor.xml:




android:src="@drawable/editor_bg"
android:tileMode="repeat" />


editor_bg is a .png file located int he drawable folder.


The end result is the EditorActivity gets launched, and all I see is the default black background with the "Editor" text displayed in white (I added that to test that the XML file was loading correctly.


I've also tried setting the background of the FrameLayout and TextView to transparent via android:background="@android:color/transparent", thinking maybe they were defaulting to a black background, but no luck.


It's been a long few days, I'm sure I am missing something simple... any obvious mistakes I am making here?


Thanks.



.

stackoverflow.comm

[General] problem with CM 10.1


I have a razr HD maxx and I flashed CM 10.1 on my deveice so it running jb 4.2.2. the ROM has superuser installed, but im unable to start any recovery safestrap, or get bootstrao CMW or anything on the phone. i would like to test out other ROMs. is there a way to do this. when i put it in AP fastboot the cpu doesnt recognize commands im giving it. i have the latest drivers and phone is in debugging mode. Any ideas?



.

forum.xda-developers.com

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...