loading...
Mostrando entradas con la etiqueta Android. Mostrar todas las entradas
Mostrando entradas con la etiqueta Android. Mostrar todas las entradas

domingo, 17 de agosto de 2014

Android incluirá soporte para múltiples usuarios

Los propietarios de tablets Android han tenido acceso a la opción para crear distintos usuarios en sus dispositivos desde el año pasado, y ahora el sistema estaría por llegar a los móviles que usen el software de Google. La nueva funcionalidad no había sido implementada en teléfonos porque, según aclaró el gigante de internet, no había una buena manera de administrar las llamadas entrantes entre varios usuarios. Parece que esa complicación ha sido solucionada, porque el soporte multiusuario estará disponible "como parte del próximo build público".

Entendemos que la opción para bloquear aplicaciones específicas o incluir contraseñas funcionará como en los tablets, y suponemos que esto estará disponible en Android L, y no antes. En todo caso, debe aclararse que el soporte multiusuario fue mencionado por un empleado de Google en la página para desarrolladores de Android, y no con una nota de prensa oficial de la compañía. A pesar de eso, este empleado dijo que la función ya ha sido implementada por el equipo de desarrollo en versiones de prueba del software, por lo que suponemos que no faltará mucho para incluirla como opción oficial.

miércoles, 23 de enero de 2013

string[] ct_name = null;

string[] ct_name = null;

  package com.phpserver;   import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;   import android.app.ListActivity;
import android.net.ParseException;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;   public class send1 extends ListActivity {
int ct_id;
String[] ct_name = null;   @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.main);
String result = null;
InputStream is = null;
StringBuilder sb = null;
// http post
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://10.0.2.2:8086/city.php");
// httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
} catch (Exception e) {
Log.e("log_tag", "Error in http connection" + e.toString());
}
// convert response to string
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
sb = new StringBuilder();
sb.append(reader.readLine() + "\n");
String line = "0";
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result = sb.toString();
} catch (Exception e) {
Log.e("log_tag", "Error converting result " + e.toString());
}
// paring data
JSONArray jArray;
try {
jArray = new JSONArray(result);
JSONObject json_data = null;
ct_name = new String[jArray.length()];
for (int i = 0; i < jArray.length(); i++) {
json_data = jArray.getJSONObject(i);
ct_id = json_data.getInt("CITY_ID");
ct_name[i] = json_data.getString("CITY_NAME");
}
} catch (JSONException e1) {
Toast.makeText(getBaseContext(), "No City Found", Toast.LENGTH_LONG)
.show();
} catch (ParseException e1) {
e1.printStackTrace();
}
setListAdapter(new ArrayAdapter<string>(this,
android.R.layout.simple_list_item_1, ct_name));
ListView lv;
lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView int position, long id) {
// When clicked, show a toast with the TextView text
Toast.makeText(getApplicationContext(),
ct_name[position] + " wasClicked", Toast.LENGTH_SHORT)
.show();
}   });
}
}</string>
-------------------------------------------------------------------------
PHP code for receiving data:
-------------------------------------------------------------------------

Collapse | Copy Code

$hostname_localhost ="localhost";
$database_localhost ="mydatabase";
$username_localhost ="root";
$password_localhost ="";   $localhost = mysql_connect($hostname_localhost,$username_localhost,$password_localhost)
or
trigger_error(mysql_error(),E_USER_ERROR);   mysql_select_db("Deal");
$sql=mysql_query("select * from CITY where CITY_NAME like 'A%'");
while($row=mysql_fetch_assoc($sql))
$output[]=$row;
print(json_encode($output));
mysql_close();
?>

-------------------------------------------------------------------------
java code for Insert data:
-------------------------------------------------------------------------

Collapse | Copy Code

 package com.Insert;   import java.io.InputStream;
import java.util.ArrayList;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import android.app.ListActivity;
import android.os.Bundle;
import android.util.Log;   public class Insert extends ListActivity {
String[] ct_name = null;   @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.main);

InputStream is = null;
// http post
ArrayList<namevaluepair> nameValuePairs = new ArrayList<namevaluepair>(); nameValuePairs.add(new BasicNameValuePair("c_name","KL"));
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://10.0.2.2:8086/city1.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e){
Log.e("log_tag", "Error in http connection"+e.toString());
}
}

}

-------------------------------------------------------------------------
PHP code for Insert data:
-------------------------------------------------------------------------

Collapse | Copy Code

 $hostname_localhost ="localhost";
$database_localhost ="mydatabase";
$username_localhost ="root";
$password_localhost ="";   $localhost = mysql_connect($hostname_localhost,$username_localhost,$password_localhost)
or
trigger_error(mysql_error(),E_USER_ERROR);   mysql_select_db("Deal");
$sql=mysql_query("INSERT INTO CITY (CITY_NAME)VALUES('".$_REQUEST['c_name']."')");
//for updation
//$sql=update CITY set CITY_NAME='".$_REQUEST['c_name']."' where CITY_ID=22
$r=mysql_query($sql);
if(!$r)
echo "Error in query: ".mysql_error();
mysql_close();
?>

********************Add

Collapse | Copy Code

 <uses-permission android:name="android.permission.INTERNET" xmlns:android="#unknown"></uses-permission>
to AndroidManifest
To connect to your emulator, you can use this link: http://10.0.2.2:8080/.

domingo, 9 de septiembre de 2012

DatePicker, DatePickerDialog

Puede muy fácilmente tener acceso a la DatePicker objeto encapsulado por el DatePickerDialog mediante la reflexión

DatePickerDialog dialog = ... // create dialog
Field mDatePickerField = dialog.getClass().getDeclaredField("mDatePicker");
mDatePickerField.setAccessible(true);
DatePicker mDatePickerInstance = (DatePicker) mDatePickerField.get(dialog);

Ejemplos para ser aplicados:


 


android.app.DatePickerDialog


final Calendar cal = Calendar.getInstance();

final Long time = getValue();

if (time != null) {

    cal.setTimeInMillis(time.longValue());

}

return new DatePickerDialog(

        getContext(),

        this,

        cal.get(Calendar.YEAR),

        cal.get(Calendar.MONTH),

        cal.get(Calendar.DAY_OF_MONTH));

 

  switch (id) {

        case TIME_DIALOG_ID:

            return new TimePickerDialog(this,

                    mTimeSetListener, mHour, mMinute, false);

        case DATE_DIALOG_ID:

            return new DatePickerDialog(this,

                        mDateSetListener,

                        mYear, mMonth, mDay);

    }

    return null;

}


@Override

protected Dialog onCreateDialog(int id) {

    switch (id) {

    case DATE_DIALOG_ID:

        return new DatePickerDialog(this, this, mYear, mMonth, mDay);

    default:

        break;

    }

    return null;

}








      }

    });

     

    mMonthButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View view) {

            new DatePickerDialog(BudgetList.this, mDateSetListener, Buxoid.mYear, Buxoid.mMonth, 1).show();

        }

    });

     

    registerForContextMenu(getListView());

}


    }

    });

     

    mMonthButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View view) {

            new DatePickerDialog(Analysis.this, mDateSetListener, Buxoid.mYear, Buxoid.mMonth, 1).show();

        }

    });

}

 

 









});

 

// set the onclick listener for the change date button

mDate.setOnClickListener(new View.OnClickListener() {

    public void onClick(View view) {

        new DatePickerDialog(EditTransaction.this, mDateSetListener, mYear, mMonth-1, mDay).show();

    }

});

 

mTransId = icicle != null ? icicle.getLong(BuxoidDb.TRANS_ROWID) : null;

mAccountId = icicle != null ? icicle.getString(BuxoidDb.TRANS_ACCOUNTID) : null;