Tuesday, May 14, 2013

[android help] Logcat message: error opening trace file: No such file or directory (2) Can anyone help me?


Java Code: public class SplashActivity extends Activity implements OnClickListener {



@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome);

//////////////////////////////////////////////////////////////////////
//////// GAME MENU /////////////////////////////////////////////////
Button playBtn = (Button) findViewById(R.id.playBtn);
playBtn.setOnClickListener(this);
Button settingsBtn = (Button) findViewById(R.id.settingsBtn);
settingsBtn.setOnClickListener(this);
Button rulesBtn = (Button) findViewById(R.id.rulesBtn);
rulesBtn.setOnClickListener(this);
Button exitBtn = (Button) findViewById(R.id.exitBtn);
exitBtn.setOnClickListener(this);
}


/**
* Listener for game menu
*/
@Override
public void onClick(View v) {
Intent i;

switch (v.getId()){
case R.id.playBtn :
//once logged in, load the main page
//Log.d("LOGIN", "User has started the game");

//Get Question set //
List questions = getQuestionSetFromDb();

//Initialise Game with retrieved question set ///
GamePlay c = new GamePlay();
c.setQuestions(questions);
c.setNumRounds(getNumQuestions());
((ChuckApplication)getApplication()).setCurrentGame(c);

//Start Game Now.. //
i = new Intent(this, QuestionActivity.class);
startActivityForResult(i, Constants.PLAYBUTTON);
break;

case R.id.rulesBtn :
i = new Intent(this, RulesActivity.class);
startActivityForResult(i, Constants.RULESBUTTON);
break;

case R.id.settingsBtn :
i = new Intent(this, SettingsActivity.class);
startActivityForResult(i, Constants.SETTINGSBUTTON);
break;

case R.id.exitBtn :
finish();
break;
}

}


/**
* Method that retrieves a random set of questions from
* the database for the given difficulty
* @return
* @throws Error
*/
private List getQuestionSetFromDb() throws Error {
int diff = getDifficultySettings();
int numQuestions = getNumQuestions();
DBHelper myDbHelper = new DBHelper(this);
try {
myDbHelper.createDataBase();
} catch (IOException ioe) {
throw new Error("Unable to create database");
}
try {
myDbHelper.openDataBase();
}catch(SQLException sqle){
throw sqle;
}
List questions = myDbHelper.getQuestionSet(diff, numQuestions);
myDbHelper.close();
return questions;
}


/**
* Method to return the difficulty settings
* @return
*/
private int getDifficultySettings() {
SharedPreferences settings = getSharedPreferences(Constants.SETTINGS, 0);
int diff = settings.getInt(Constants.DIFFICULTY, Constants.MEDIUM);
return diff;
}

/**
* Method to return the number of questions for the game
* @return
*/
private int getNumQuestions() {
SharedPreferences settings = getSharedPreferences(Constants.SETTINGS, 0);
int numRounds = settings.getInt(Constants.NUM_ROUNDS, 20);
return numRounds;
}


}


when i hit the play button, the application stops. This button has to take to new activity to open a quiz qith 4 option radio button connected to a sqlite database.


Logcat messaege:



`05-14 07:44:38.109: E/Trace(723): error opening trace file: No such file or directory (2)
05-14 07:44:39.629: D/dalvikvm(723): GC_FOR_ALLOC freed 203K, 13% free 2480K/2828K, paused 330ms, total 366ms
05-14 07:44:40.249: I/Choreographer(723): Skipped 69 frames! The application may be doing too much work on its main thread.
05-14 07:44:40.859: D/gralloc_goldfish(723): Emulator without GPU emulation detected.
05-14 07:44:57.139: E/SQLiteLog(723): (14) cannot open file at line 30176 of [00bb9c9ce4]
05-14 07:44:57.139: E/SQLiteLog(723): (14) os_unix.c:30176: (2) open(/data/data/com.pixy.quiz/databases/questionsDb) -
05-14 07:44:57.299: E/SQLiteDatabase(723): Failed to open database '/data/data/com.pixy.quiz/databases/questionsDb'.
05-14 07:44:57.299: E/SQLiteDatabase(723): android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
05-14 07:44:57.299: E/SQLiteDatabase(723): at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
05-14 07:44:57.299: E/SQLiteDatabase(723): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209)
05-14 07:44:57.299: E/SQLiteDatabase(723): at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
05-14 07:44:57.299: E/SQLiteDatabase(723): at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
05-14 07:44:57.299: E/SQLiteDatabase(723): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
05-14 07:44:57.299: E/SQLiteDatabase(723): at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
05-14 07:44:57.299: E/SQLiteDatabase(723): at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:804)
05-14 07:44:57.299: E/SQLiteDatabase(723): at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:789)
05-14 07:44:57.299: E/SQLiteDatabase(723): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
05-14 07:44:57.299: E/SQLiteDatabase(723): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:669)
05-14 07:44:57.299: E/SQLiteDatabase(723): at com.pixy.quiz.db.DBHelper.checkDataBase(DBHelper.java:69)
05-14 07:44:57.299: E/SQLiteDatabase(723): at com.pixy.quiz.db.DBHelper.createDataBase(DBHelper.java:46)
05-14 07:44:57.299: E/SQLiteDatabase(723): at com.pixy.quiz.SplashActivity.getQuestionSetFromDb(SplashActivity.java:97)
05-14 07:44:57.299: E/SQLiteDatabase(723): at com.pixy.quiz.SplashActivity.onClick(SplashActivity.java:55)
05-14 07:44:57.299: E/SQLiteDatabase(723): at android.view.View.performClick(View.java:4204)
05-14 07:44:57.299: E/SQLiteDatabase(723): at android.view.View$PerformClick.run(View.java:17355)
05-14 07:44:57.299: E/SQLiteDatabase(723): at android.os.Handler.handleCallback(Handler.java:725)
05-14 07:44:57.299: E/SQLiteDatabase(723): at android.os.Handler.dispatchMessage(Handler.java:92)
05-14 07:44:57.299: E/SQLiteDatabase(723): at android.os.Looper.loop(Looper.java:137)
05-14 07:44:57.299: E/SQLiteDatabase(723): at android.app.ActivityThread.main(ActivityThread.java:5041)
05-14 07:44:57.299: E/SQLiteDatabase(723): at java.lang.reflect.Method.invokeNative(Native Method)
05-14 07:44:57.299: E/SQLiteDatabase(723): at java.lang.reflect.Method.invoke(Method.java:511)
05-14 07:44:57.299: E/SQLiteDatabase(723): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-14 07:44:57.299: E/SQLiteDatabase(723): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-14 07:44:57.299: E/SQLiteDatabase(723): at dalvik.system.NativeStart.main(Native Method)
05-14 07:44:57.369: D/dalvikvm(723): GC_CONCURRENT freed 276K, 14% free 2633K/3052K, paused 73ms+45ms, total 220ms
05-14 07:44:57.610: D/AndroidRuntime(723): Shutting down VM
05-14 07:44:57.610: W/dalvikvm(723): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
05-14 07:44:57.649: E/AndroidRuntime(723): FATAL EXCEPTION: main
05-14 07:44:57.649: E/AndroidRuntime(723): java.lang.ClassCastException: android.app.Application cannot be cast to com.pixy.quiz.ChuckApplication
05-14 07:44:57.649: E/AndroidRuntime(723): at com.pixy.quiz.SplashActivity.onClick(SplashActivity.java:61)
05-14 07:44:57.649: E/AndroidRuntime(723): at android.view.View.performClick(View.java:4204)
05-14 07:44:57.649: E/AndroidRuntime(723): at android.view.View$PerformClick.run(View.java:17355)
05-14 07:44:57.649: E/AndroidRuntime(723): at android.os.Handler.handleCallback(Handler.java:725)
05-14 07:44:57.649: E/AndroidRuntime(723): at android.os.Handler.dispatchMessage(Handler.java:92)
05-14 07:44:57.649: E/AndroidRuntime(723): at android.os.Looper.loop(Looper.java:137)
05-14 07:44:57.649: E/AndroidRuntime(723): at android.app.ActivityThread.main(ActivityThread.java:5041)
05-14 07:44:57.649: E/AndroidRuntime(723): at java.lang.reflect.Method.invokeNative(Native Method)
05-14 07:44:57.649: E/AndroidRuntime(723): at java.lang.reflect.Method.invoke(Method.java:511)
05-14 07:44:57.649: E/AndroidRuntime(723): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-14 07:44:57.649: E/AndroidRuntime(723): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-14 07:44:57.649: E/AndroidRuntime(723): at dalvik.system.NativeStart.main(Native Method)
05-14 07:49:57.010: I/Process(723): Sending signal. PID: 723 SIG: 9
`


My BDHelper Class:


public class DBHelper extends SQLiteOpenHelper{



//The Android's default system path of your application database.
private static String DB_PATH = "/data/data/com.pixy.quiz/databases/";
private static String DB_NAME = "questionsDb";
private SQLiteDatabase myDataBase;
private final Context myContext;

/**
* Constructor
* Takes and keeps a reference of the passed context in order to access to the application assets and resources.
* @param context
*/
public DBHelper(Context context) {
super(context, DB_NAME, null, 1);
this.myContext = context;
}

/**
* Creates a empty database on the system and rewrites it with your own database.
* */
public void createDataBase() throws IOException{

boolean dbExist = checkDataBase();
if(!dbExist)
{
//By calling this method and empty database will be created into the default system path
//of your application so we are gonna be able to overwrite that database with our database.
this.getReadableDatabase();

try {
copyDataBase();
} catch (IOException e) {
throw new Error("Error copying database");
}
}
}

/**
* Check if the database already exist to avoid re-copying the file each time you open the application.
* @return true if it exists, false if it doesn't
*/
private boolean checkDataBase(){
SQLiteDatabase checkDB = null;
try{
String myPath = DB_PATH + DB_NAME;
checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
}catch(SQLiteException e){
//database does't exist yet.
}
if(checkDB != null){
checkDB.close();
}

return checkDB != null ? true : false;
}

/**
* Copies your database from your local assets-folder to the just created empty database in the
* system folder, from where it can be accessed and handled.
* This is done by transfering bytestream.
* */
private void copyDataBase() throws IOException{

//Open your local db as the input stream
InputStream myInput = myContext.getAssets().open(DB_NAME);

// Path to the just created empty db
String outFileName = DB_PATH + DB_NAME;

//Open the empty db as the output stream
OutputStream myOutput = new FileOutputStream(outFileName);

//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer))>0){
myOutput.write(buffer, 0, length);
}

//Close the streams
myOutput.flush();
myOutput.close();
myInput.close();

}

public void openDataBase() throws SQLException{
//Open the database
String myPath = DB_PATH + DB_NAME;
myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
}

@Override
public synchronized void close() {
if(myDataBase != null)
myDataBase.close();
super.close();
}

@Override
public void onCreate(SQLiteDatabase db) {
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}

// Add your public helper methods to access and get content from the database.
// You could return cursors by doing "return myDataBase.query(....)" so it'd be easy
// to you to create adapters for your views.




public List getQuestionSet(int difficulty, int numQ){
List questionSet = new ArrayList();
Cursor c = myDataBase.rawQuery("SELECT * FROM question WHERE DIFFICULTY=" + difficulty +
" ORDER BY RANDOM() LIMIT " + numQ, null);
while (c.moveToNext()){
//Log.d("QUESTION", "Question Found in DB: " + c.getString(1));
Question q = new Question();
q.setQuestion(c.getString(1));
q.setAnswer(c.getString(2));
q.setOption1(c.getString(3));
q.setOption2(c.getString(4));
q.setOption3(c.getString(5));
q.setRating(difficulty);
questionSet.add(q);
}
return questionSet;
}


}



.

stackoverflow.comm

[General] How to get Google+ Instant Upload free storage for any photo


You know that Google+ Instant Upload photos don't count against your storage, but do you want that free storage for any photo at all? Here is a little workaround

Simple, but effective: just hook your phone up to your computer and drag and drop any photos you want into your phone's camera folder and, viola, they are treated like newly taken photos and uploaded to G+. (or use a file manager right on your phone to copy and paste there). Then, just delete those photos from the camera folder afterwards.

Now, keep in mind that they will be reduced to the "free upload" pixel limit of 2048, just like any other instant uploads, but for many of us, our camera phone pictures are not much bigger anyway.

Extra pro-tip: videos are also "free storage" and they don't reduce their quality at all. You can really maximize your free G+ storage with video.



.

forum.xda-developers.com

[android help] Change TextView inside Fragment

android - Change TextView inside Fragment - Stack Overflow







Tell me more ×

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

















I followed this guy's tutorial on how to make an ActionBar. Let's say I want to change the TextView inside one of the fragments. So I added this on my StartActivity.java, under onCreate:



TextView textview = (TextView) findViewById(R.id.textView1);
textview.setText("HI!");


When I start my app, it crashes. Can somebody point me to the right direction?


I hope somebody takes the time to look at the guy's tutorial because his layout is basically the same as mine. Thank you.


























If you want change your component, I suggest you to make a method inside the fragment like this:



import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class DetailFragment extends Fragment {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.details, container, false);
return view;
}


public void setText(String text){
TextView textView = (TextView) getView().findViewById(R.id.detailsText);
textView.setText(text);
}

}






















default






.

stackoverflow.comm

[General] why does my brand new samsung galaxy 2 say generic in the right corner of the screen?


I just bought this phone today with my mother. We both got the same exact phone, except her settings are different than mine. like its better and she had options to change her settings from scratch and mine was just there and i cant change a thing. also it says generic in the top right corner and i don't even know what that is all about.
An additional question, why is there a red light beeping in the top corner of phone.



.

forum.xda-developers.com

[android help] Creating the folder with password protection


I am trying to create the media recorder for Android by creating the folders with password protection and audio files inside.


But now I only can create the folder and audio files which other Apps and user of the Android smartphone to access.


The purpose of implementing password protection is to not to let other Apps or users can access the file and folders unless password is provided?


Are there any ideas how to achieve this besides creating the password entering panel?


The below is my code.



public void onClick(View view) throws Exception {
if (count == 0) {

tbxRecordStatus.setText("Record");
btnRecord.setText("Stop Record");
Toast.makeText(MainActivity.this, "Recording Starts",
Toast.LENGTH_SHORT).show();
String dateInString = new SimpleDateFormat(
"yyyy-MM-dd-HH-mm-ss").format(new Date()).toString();
String fileName = "TasB_" + dateInString + " record.3gp";
SDCardpath = Environment.getExternalStorageDirectory();
myDataPath = new File(SDCardpath.getAbsolutePath() + "/My Recordings");
if (!myDataPath.exists())
myDataPath.mkdir();

audiofile = new File(myDataPath + "/" + fileName);
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setAudioEncodingBitRate(16);
recorder.setAudioSamplingRate(44100);
recorder.setOutputFile(audiofile.getAbsolutePath());



try
{
recorder.prepare();
}
catch (Exception e)
{
e.printStackTrace();
}
recorder.start();
count++;

} else {

tbxRecordStatus.setText("Stop");
btnRecord.setText("Start Record");
Toast.makeText(MainActivity.this, "Recording Stops",
Toast.LENGTH_SHORT).show();
if (recorder != null) {
recorder.stop();
recorder.release();
recorder = null;

} else {
tbxRecordStatus.setText("Warning!");
Toast.makeText(MainActivity.this, "Record First",
Toast.LENGTH_SHORT).show();
}
count = 0;
}
}


.

stackoverflow.comm

[General] Using old Evo 4G as media server?


Hi,

I just upgraded to the Galaxy S4 and was thinking about what to do with my old HTC Evo. I was wondering if there is any simple way to control my old Evo (over WiFi) with my S4, so I could stream Netflix from my Evo through my TV (with the micro hdmi cable).

Basically using my Evo to push Netflix to my TV, controlled by my S4.

Thank you!



.

forum.xda-developers.com

[android help] Marker is not removing from mapV2 android


I am adding a maker on touch of map and want to remove that marker on click of some button but that marker is not removing from map .Here is my Code



// Marker of end Point
Marker endPointMarker;


onclick of map



@Override
public void onMapClick(LatLng point) {
// TODO Auto-generated method stub
double lat = point.latitude;
double lng = point.longitude;

// Add marker of destination point

try {
Geocoder geocoder;
List
addresses;
geocoder = new Geocoder(BookCabScreen.this);
if (lat != 0 || lng != 0) {
addresses = geocoder.getFromLocation(lat, lng, 1);
String address = addresses.get(0).getAddressLine(0);
String city = addresses.get(0).getAddressLine(1);
String country = addresses.get(0).getAddressLine(2);
Log.d("TAG", "address = " + address + ", city =" + city
+ ", country = " + country);
endPointMarker = mMap.addMarker(new MarkerOptions()
.position(new LatLng(lat, lng))
.title("Location").snippet("" + address));

markers.add(mMap.addMarker(new MarkerOptions()
.position(new LatLng(lat, lng))
.title("Location").snippet("" + address)));
btnStartUp.setEnabled(true);
btnStopPoint.setEnabled(true);

mJbBookCab.setEndPointLat(lat);
mJbBookCab.setEndPointLng(lng);
} else {
Toast.makeText(BookCabScreen.this,
"latitude and longitude are null",
Toast.LENGTH_LONG).show();

}
} catch (Exception e) {
e.printStackTrace();

}


}


on click of button



if (endPointMarker != null) {
endPointMarker.remove();

endPointMarker = null;
}


But it is not removing from map ?Please help



.

stackoverflow.comm

[General] Call Waiting Beep Heard By 2nd Caller


I have the Galaxy S2 jelly bean version. My problem is that when I am on a call and I receive another call, I get the notification beeping sound, and the person I am talking to also hears the beep and becomes aware that someone is trying to call me! The person I'm talking to should not hear the beep or know that I'm being called by a third person!

How can I resolve this issue? And how to prevent/turn off the beep to the person I am talking to without turning off call waiting ?

Please help.

Thanks.



.

forum.xda-developers.com

[android help] Search through android app


Are you trying to implement search functionality in listView...


you can create EditText above ListView and implement TextChangeListener...


In here, as per the input string of EditText you can filter the listView.



inputSearch.addTextChangedListener(new TextWatcher() {

@Override
public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
// When user changed the Text
MainActivity.this.adapter.getFilter().filter(cs);
}

@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub

}

@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
});


Try this link..


This will guide you in proper direction..


Let me know if you want something else..



.

stackoverflow.comm

[android help] encryption and decryption using RSA in android app


i have been trying to develop an android app which could encrypt and decrypt the SMS of the inbox..but there is some error in the public key and private key.. here is my code



public static PublicKey generateRsaPublicKey(BigInteger modulus, BigInteger publicExponent)
{
try
{
return KeyFactory.getInstance("RSA").generatePublic(new RSAPublicKeySpec(modulus, publicExponent));
}
catch(Exception e)
{
// Logger.e(e.toString());
}
return null;
}

public static PrivateKey generateRsaPrivateKey(BigInteger modulus, BigInteger privateExponent)
{
try
{
return KeyFactory.getInstance("RSA").generatePrivate(new RSAPrivateKeySpec(modulus, privateExponent));
}
catch(Exception e)
{
// Logger.e(e.toString());
}
return null;
}

public static byte[] rsaEncrypt(byte[] name, PublicKey key)
{
try
{
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.ENCRYPT_MODE, key);
return cipher.doFinal(name);
}
catch(Exception e)
{
// Logger.e(e.toString());
}
return null;
}

public static byte[] rsaDecrypt(byte[] dsms, PrivateKey key)
{
try
{
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.DECRYPT_MODE, key);
return cipher.doFinal(dsms);
}
catch(Exception e)
{
// Logger.e(e.toString());
}
return null;
}


code for encrypt-



String data = StringCryptor.rsaEncrypt( byte[] name, PublicKey );
String enSMS=sender + "\n" + data;
//Toast.makeText( this, data, Toast.LENGTH_SHORT).show();
EditText txtEncryptSMS = (EditText) findViewById(R.id.EncryptText);
txtEncryptSMS.setText(enSMS);

Uri uriSms = Uri.parse("content://sms/inbox");
Cursor c = getContentResolver().query(uriSms, null,null,null,null);
//int id = c.getInt(0);
//int thread_id = c.getInt(1); //get the thread_id
getContentResolver().delete(Uri.parse("content://sms/" + msgid),null,null);

ContentValues values = new ContentValues();
values.put("address", sender);
values.put("body", data);
//values.put("type", 2);
//values.put("date", rcvdDateTime);

getContentResolver().insert(Uri.parse("content://sms/inbox"), values);

}


code for decrypt-



String data = StringCryptor.rsaDecrypt( byte[] name, PrivateKey );
String enSMS=sender + "\n" + data;
//Toast.makeText( this, data, Toast.LENGTH_SHORT).show();
EditText txtEncryptSMS = (EditText) findViewById(R.id.EncryptText);
txtEncryptSMS.setText(enSMS);

Uri uriSms = Uri.parse("content://sms/inbox");
Cursor c = getContentResolver().query(uriSms, null,null,null,null);
//int id = c.getInt(0);
//int thread_id = c.getInt(1); //get the thread_id
getContentResolver().delete(Uri.parse("content://sms/" + msgid),null,null);

ContentValues values = new ContentValues();
values.put("address", sender);
values.put("body", data);
//values.put("type", 2);
//values.put("date", rcvdDateTime);

getContentResolver().insert(Uri.parse("content://sms/inbox"), values);

}


.

stackoverflow.comm

[android help] Formatting Double with two dp


From my decimalForm method below, i want to convert double value 7777.54 to 7 777,54 but i am getting 7 777 54. what have missed ? result should be 7 777,54



public static String decimalForm(double value){

DecimalFormat df = new DecimalFormat("#,###,###.00");
String formatted_value = df.format(value).replaceAll(",", " ").replace(".", ",");

return formatted_value;
}


.

stackoverflow.comm

[android help] R file is missing android


I had this same issue today and figured it out. The reason this happens so often when including external/example files is because often times these examples reference layouts in your application, but do not have access to the package and therefore cannot see the R.java file in that package. to make things clear, here's the beginning of the R.java file:



/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/

package com.conceptualsystems.dashboard;

public final class R {
public static final class attr {
}
public static final class drawable {
public static final int csc_logo=0x7f020000;
public static final int icon=0x7f020001;
}
public static final class id {
public static final int activation_code=0x7f070012;
public static final int alpha_bar=0x7f07000b;
public static final int alpha_label=0x7f07000a;


notice the package name is whatever the package name of your application is. .java files that are not included in this package (ie, your example code you just dropped in) will need to explicitly reference that package file like this:



package com.example.android.apis.graphics;

import android.app.Dialog;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.SeekBar;
import com.conceptualsystems.dashboard.R;


the last line is the one to pay attention to. after importing the resources explicitly, the resources will be available in your example code.



.

stackoverflow.comm

[android help] How do you implement a FileObserver from an Android Service


How do you structure an Android app to start a Service to use a FileObserver so that when the observed directory is modified (ie user takes picture) some other code executes. When debugging, the onEvent method is never triggered.


Here is the onStart event I have in my Service. The Toast fires for "My Service Started..."



public final String TAG = "DEBUG";
public static FileObserver observer;

@Override
public void onStart(Intent intent, int startid) {
Log.d(TAG, "onStart");

final String pathToWatch = android.os.Environment.getExternalStorageDirectory().toString() + "/DCIM/Camera/";
Toast.makeText(this, "My Service Started and trying to watch " + pathToWatch, Toast.LENGTH_LONG).show();

observer = new FileObserver(pathToWatch) { // set up a file observer to watch this directory on sd card
@Override
public void onEvent(int event, String file) {
//if(event == FileObserver.CREATE && !file.equals(".probe")){ // check if its a "create" and not equal to .probe because thats created every time camera is launched
Log.d(TAG, "File created [" + pathToWatch + file + "]");

Toast.makeText(getBaseContext(), file + " was saved!", Toast.LENGTH_LONG);
//}
}
};
}


But after that Toast, if I take a picture the onEvent never fires. This is determined by debugging. It never hits that breakpoint and the Toast never fires.


When that directory is browsed, the new image is saved there.


How do you get a FileObserver working in a Service?



.

stackoverflow.comm

[android help] After parsing, the images in imageview of listview are not the right images(random image)


I made oneListView withimageview and textview. After parsing json data i am getting right text intextview but the image inimageview are not the right image.How can i make it correct? thanks in advance..


My code for parser.java class.



public class Parser {
private ArrayList mDataSource = new ArrayList();
public Parser(String json) {
jsonParser(json);
}
private void jsonParser(String json) {
try {
JSONObject obj = new JSONObject(json);
//JSONObject var = obj.getJSONObject("activities");
JSONArray list = obj.getJSONArray("activities");
int len = list.length();
for (int i = 0; i < len; i++) {
try {
JSONObject data = list.getJSONObject(i);
String summary=data.getString("type");
String state ;
String title ;
String image ;
String concatinate;
String review ;
String status ;
String url ;
//String image1;

// String image1;
ArrayList addList = new ArrayList();
JSONArray addArray = obj.getJSONArray("activities");
int size = addArray.length();
/**
* parser sub json
*/
for(int j = 0; j < size; j++) {
addList.add(addArray.getJSONObject(j).getString("activity_id"));
}

if(summary.contains("user")){
url= data.getString("user_name");
title = data.getString("time");
image = data.getString("thumb");
// if(image.contains("false")){
// image="http://www.etablecdn.com//user//uploads//varun.nayyar405@gmail.com//varun.nayyar405.jpg";
// }


concatinate=url+" "+"joined the etable community";
review=null;
status=null;
state=null;
//image1=null;

mDataSource.add(new Data(state, image, title, summary, addList, url,concatinate,review,status));
}else if(summary.contains("checkin")){
url= data.getString("user_name");
title = data.getString("time");
state=data.getString("subscriber_name");
image = data.getString("thumb");
// if(image.contains("false")){
// image="http://www.etablecdn.com//user//uploads//varun.nayyar405@gmail.com//varun.nayyar405.jpg";
// }
concatinate=url+" "+"was spotted at"+" "+state;
review=null;
status=null;
// image1=data.getString("thumb");
mDataSource.add(new Data(state, image, title, summary, addList, url,concatinate,review,status));
}else if(summary.contains("favorite")){
url= data.getString("user_name");
title = data.getString("time");
state=data.getString("subscriber_name");
image = data.getString("thumb");
// if(image.contains("false")){
// image="http://www.etablecdn.com//user//uploads//varun.nayyar405@gmail.com//varun.nayyar405.jpg";
// }
concatinate=url+" "+"favorited"+" "+state;
// image1=data.getString("thumb");
review=null;
status=null;
mDataSource.add(new Data(state, image, title, summary, addList, url,concatinate,review,status));

}else if(summary.contains("review")){
url= data.getString("user_name");
title = data.getString("time");
state=data.getString("subscriber_name");
image = data.getString("thumb");
// if(image.contains("false")){
// image="http://www.etablecdn.com//user//uploads//varun.nayyar405@gmail.com//varun.nayyar405.jpg";
// }
concatinate=url+" "+"wrote a review for"+" "+state;
review=data.getString("review_full");
// image1=data.getString("thumb");
status=null;
mDataSource.add(new Data(state, image, title, summary, addList, url,concatinate,review,status));

}else if(summary.contains("status")){
url= data.getString("user_name");
title = data.getString("time");
image = data.getString("thumb");
// if(image.contains("false")){
// image="http://www.etablecdn.com//user//uploads//varun.nayyar405@gmail.com//varun.nayyar405.jpg";
// }
status=data.getString("full_status");
concatinate=url+" "+"saya\n"+""+status;
// image1=null;
review=null;
state=null;
mDataSource.add(new Data(state, image, title, summary, addList, url,concatinate,review,status));
}else if(summary.contains("photo_upload")){
url= data.getString("user_name");
title = data.getString("time");
image = data.getString("thumb");
// if(image.contains("false")){
// image="http://www.etablecdn.com//user//uploads//varun.nayyar405@gmail.com//varun.nayyar405.jpg";
// }
state=data.getString("subscriber_name");
concatinate=url+" "+"uploaded a photo of"+" "+state;
//image1=data.getString("thumb");
review=null;
status=null;
mDataSource.add(new Data(state, image, title, summary, addList, url,concatinate,review,status));
}



else{
url= data.getString("user_name");
title = data.getString("time");
image = data.getString("thumb");
/// if(image.contains("false")){
// image="http://www.etablecdn.com//user//uploads//varun.nayyar405@gmail.com//varun.nayyar405.jpg";
// }
status=null;
concatinate=url+" "+"some data missing";
review=null;
state=null;
// image1=null;
mDataSource.add(new Data(state, image, title, summary, addList, url,concatinate,review,status));
}



} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}


} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

public ArrayList getSource() {
return mDataSource;
}}


code of Adapter.java



public class Adapter extends BaseAdapter {

private static final String TAG = "Adapter";
private Activity mActivity;
public ArrayList mObjects;
// /private final Context context;
Context context;

static class ViewHolder {
static ImageView icon;
TextView title;
TextView name;
TextView review;
DownloadImageTask mTask;
String ab[];
// DownloadImageTask1 mTask1;
// ImageView photo;
}

public Adapter(Activity activity, Context context, ArrayList mObjects) {

this.mActivity = (Activity) activity;
this.context = context;
this.mObjects = mObjects;

}

public void setObjects(ArrayList mObjects) {
this.mObjects = mObjects;
}

@Override
public View getView(final int position, View convertView, ViewGroup parent) {

final Data item = mObjects.get(position);
View rowView = convertView;

if (rowView == null) {
LayoutInflater inflater = mActivity.getLayoutInflater();
rowView = inflater.inflate(R.layout.item, parent, false);
ViewHolder viewHolder = new ViewHolder();
viewHolder.icon = (ImageView) rowView.findViewById(R.id.image);
// viewHolder.photo = (ImageView) rowView.findViewById(R.id.photo);
viewHolder.title = (TextView) rowView.findViewById(R.id.title);
viewHolder.name = (TextView) rowView.findViewById(R.id.name);

viewHolder.review = (TextView) rowView.findViewById(R.id.status);
rowView.setTag(viewHolder);
}

ViewHolder holder = (ViewHolder) rowView.getTag();

holder.title.setText(item.getmTitle());
holder.name.setText(item.getmConcatinate());

holder.review.setText(item.getmreview());
holder.icon.setBackgroundResource(R.drawable.ic_ab);
// holder.photo.setBackgroundResource(0);
holder.mTask = new DownloadImageTask(item.getmImageUrl(), holder.icon);
if (!holder.mTask.isCancelled()) {
holder.mTask.execute();
}

ViewHolder.icon.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
Log.d("Parsing JSON Data", "Before user try122222"); // perform
//Object tag= v.getTag();
Log.d("Parsing JSON Data","abc");
String title = item.getmConcatinate();
String picture=item.getmImageUrl();


Intent intent = new Intent(v.getContext(), LargeView.class);
Log.d("Parsing JSON Data", "Before user try444444");
intent.putExtra("data", title);
Log.d("Parsing JSON Data", "Before user try555555");
intent.putExtra("image3",picture);
Log.d("Parsing JSON Data", "Before user try66666666");
v.getContext().startActivity(intent);
Log.d("Parsing JSON Data", "Before user try7777");
}
});

// holder.mTask1 = new DownloadImageTask1(item.getmImageUrl1(),
// holder.photo);
// if (!holder.mTask1.isCancelled()) {
// holder.mTask1.execute();
// }

return rowView;
}

@Override
public int getCount() {

return (this.mObjects.size());
}

@Override
public Object getItem(int position) {

return (this.mObjects.get(position));
}

@Override
public long getItemId(int position) {

return (position);
}

public AbsListView.RecyclerListener mRecyclerListener = new RecyclerListener() {

public void onMovedToScrapHeap(View view) {
ViewHolder viewHolder = (ViewHolder) view.getTag();
DownloadImageTask imagetask = viewHolder.mTask;
// DownloadImageTask1 imagetask1 = viewHolder.mTask1;
if (imagetask != null) {
imagetask.cancel(true);
}
// if (imagetask1 != null) {
// // imagetask1.cancel(true);
// }
}

};}


Main.java



@Override
protected void onCreate(Bundle savedInstanceState) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.detectAll().penaltyLog().build();
StrictMode.setThreadPolicy(policy);

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile3);

name = (TextView) findViewById(R.id.textView1);
bmImage2 = (ImageView) findViewById(R.id.imageView1);
address = (TextView) findViewById(R.id.textView2);
gender = (TextView) findViewById(R.id.textView3);
loyalitypoints = (TextView) findViewById(R.id.textView7);
followers = (TextView) findViewById(R.id.textView8);
following = (TextView) findViewById(R.id.textView9);
// list13 = new ArrayList>();
mListView = (ListView) findViewById(android.R.id.list);
mListView.setClickable(true);






// mListView=(ListView)findViewById(R.id.list);
mAdapter = new Adapter(this,c,mSource );
mListView.setAdapter(mAdapter);
Log.w("Parsing JSON Data", "Before Item click");

mListView.setRecyclerListener(mAdapter.mRecyclerListener);


.

stackoverflow.comm

[General] Google playstore


Hi, l'm new to android and have purchssed a Galaxy s4. Unfortunately i cannot purchase any apps just free ones because my location is not supported (Gibraltar). Is there a way around this issue? What can i do?

Posted via Android Central App



.

forum.xda-developers.com

[General] Hands free texting in Android


Hi!

I'm new to Android. Having grown tired of waiting on Sprint to put out a new Windows Phone, I succumbed to the siren song of the HTC One, which has made me pretty happy on the whole. It's a beautiful, powerful phone, and I can now have all of the apps I ever dreamed of-- certainly not the case for Windows Phone. So that's a big plus.

One thing, however, that I am missing a very great deal is the way that Windows Phone handles texting when you have headphones on. To wit: I receive an incoming message. The phone breaks in to my music to inform me of the message and asks me if I'd like it read to me. It then gives me the option of replying to the message, and, if I elect to do so, will take dictation from me and transcribe my reply, read it back to me, and either send it off or give me another stab at it, as I instruct. All of this is 100% hands-free, requiring absolutely no visual or tactile effort on my part. Nor does it require me to launch and keep running a battery-draining app.

I had come to utilize this functionality fairly heavily, so I've kinda been looking for a way to make Android behave this way, but I have failed. Before giving up completely, I thought I'd pose the problem to experienced Android fans and see if there is something that I may be overlooking.

So, is there?

My intent is not to start a religious war on phone platforms, I'm just interested in making my One work in the above manner with regards to texting.

Thank you in advance for any replies.



.

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