Friday, August 2, 2013

[android help] Basic application for Android using SIP not working proper


Basic application for Android using SIP not working proper


Basic application for Android using SIP not working proper - 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.

















Has anyone made a small basic application using SIP for android? I have tried using CSipSimple app, with SIP account on antisip.com and sip2sip.com but none of them register properly, and it gives a timeout error. Can anyone help me in this case?


I also tried those accounts with the SipDemo given with Android, and also in Linphone app. Linphone works fine with a SIP account on Linphone itself, but no other SIP accounts works.
















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










default






Read more

stackoverflow.comm



[android help] Android writing in file just last value


Android writing in file just last value


java - Android writing in file just last value - 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.

















So am developing android application for storing sensor values in one file. My main problem is that app is just writing last value in file. Basically am trying to write code which will store every sensor value to file. Am begginer in writing Android apps... Can someone please help? Here is the code:



package com.example.hello;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.os.Environment;
import android.view.Menu;
import android.widget.TextView;

public class MainActivity extends Activity {

private TextView xAxis, yAxis, zAxis;
private SensorManager sm;
private Sensor mSensor;
final File file = new File(Environment.getExternalStorageDirectory(),
"results.txt");
static FileOutputStream fos;
static OutputStreamWriter myOutWriter;
private String writeString;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
xAxis = (TextView) findViewById(R.id.xAxis);
yAxis = (TextView) findViewById(R.id.yAxis);
zAxis = (TextView) findViewById(R.id.zAxis);

sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mSensor = sm.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
try {
fos = new FileOutputStream(file);
myOutWriter = new OutputStreamWriter(fos);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

SensorEventListener sensor = new SensorEventListener() {

@Override
public void onSensorChanged(SensorEvent event) {
xAxis.setText("xAxis: " + event.values[0]);
yAxis.setText("yAxis: " + event.values[1]);
zAxis.setText("zAxis: " + event.values[2]);
String test = new String(" " + event.values[0] + " "
+ event.values[1] + " " + event.values[2]);
writeData(test);
}

@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
};

sm.registerListener(sensor,
sm.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD),
SensorManager.SENSOR_DELAY_UI);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

public static void writeData(String test) {
try {

myOutWriter.append(test);
myOutWriter.flush();
myOutWriter.close();
} catch (FileNotFoundException e) {
// handle exception
} catch (IOException e) {
// handle exception
}
}


}


























You're closing the writer every time you write without opening it again. Add logging to the exceptions instead of just leaving them empty and you should see some stacktraces.


Something along the lines of: Log.e (TAG,message,exception), so: Log.e ("MainActivity", "Failed to write values to file",e);























Try using the other constructor, by putting true as the boolean append value. http://bit.ly/16lxbld



fos = new FileOutputStream(file,true);





















Please also consider the following constructor for FileOutputStream



fos = new FileOutputStream(file,true);



















lang-java






Read more

stackoverflow.comm



[android help] Reading file takes too long


Reading file takes too long



My application starts by parsing a ~100MB file from the SD card and takes minutes to do so. To put that in perspective, on my PC, parsing the same file takes seconds.


I started by naively implementing the parser using Matcher and Pattern, but DDMS told me that 90% of the time was spent computing regular expression. And it took more than half an hour to parse the file. The pattern is ridiculously simple, a line consists of:



ID (a number) LANG (a 3-to-5 character string) DATA (the rest)


I decided to try and use String.split. It didn’t show significant improvements, probably because this function might use regular expression itself. At that point I decided to rewrite the parser entirely, and ended up on something like this:



protected Collection doInBackground( Void... params ) {
BufferedReader reader = new BufferedReader( new FileReader( sentenceFile ) );

String currentLine = null;
while ( (currentLine = reader.readLine()) != null ) {
treatLine( currentLine, allSentences );
}

reader.close();
return allSentences;
}

private void treatLine( String line, Collection allSentences ) {
char[] str = line.toCharArray();

// ...
// treat the array of chars into an id, a language and some data

allSentences.add( new Sentence( id, lang, data ) );
}


And I noticed a huge boost. It took minutes instead of half-an-hour. But I wasn’t satisfied with this so I profiled and realized that a bottleneck was BufferedReader.readLine. I wondered: it could be IO-bound, but it also could be that a lot of time is taken filling up an intermediary buffer I don’t really need. So I rewrote the whole thing using FileReader directly:



protected Collection doInBackground( Void... params ) {
FileReader reader = new FileReader( sentenceFile );
int currentChar;
while ( (currentChar = reader.read()) != -1 ) {
// parse an id
// ...

// parse a language
while ( (currentChar = reader.read()) != -1 ) {
// do some parsing stuff
}

// parse the sentence data
while ( (currentChar = reader.read()) != -1 ) {
// parse parse parse
}

allSentences.add( new Sentence( id, lang, data ) );
}

reader.close();
}


And I was quite surprised to realize that the performance was super bad. Most of the time is spent in FileReader.read, obviously. I guess reading just a char costs a lot.


Now I am a bit out of inspiration. Any tip?



Read more

stackoverflow.comm



[android help] Error switching activity


Error switching activity


android - Error switching activity - 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 am having an error when trying to switch from one activity(com.intelligent.stocktrader.MyAccount) to another(com.intelligent.stocktrader.SharePerformanceDetails).What am i doing wrong? My code has no error. Below is the log cat content.



E/AndroidRuntime(787): FATAL EXCEPTION: main
E/AndroidRuntime(787): java.lang.RuntimeException: Unable to start activity `ComponentInfo{co`m.intelligent.stocktrader/com.intelligent.stocktrader.SharePerformanceDeta`ils}: java`.lang.RuntimeException: Parcelable encountered IOException writing serializable `object (name` = org.achartengine.chart.LineChart)
E/AndroidRuntime(787): at `android.a`pp.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
E/AndroidRuntime(787): at `android.ap`p.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)

























Probably, you didn't edit the androidmanifest.xml to accept the second activity.




















default






Read more

stackoverflow.comm



[android help] assembleRelease task dependency - Ask for keystore password


assembleRelease task dependency - Ask for keystore password



To avoid writing the keystore password in plain text, I'm trying to add a dependency to the assembleRelease task created by the android Gradle plugin.


I've checked the Gradle documentation Manipulating existing tasks but I'm unable to place the dependency where it should


This is my task, defined in $root$/myApp/build.gradle above the android plugin.



task readPasswordFromInput << {
def console = System.console()

ext.keystorePassword = console.readLine('\n\n\n> Enter keystore password: ')
}

apply plugin: 'android'


Then, I've tried the two possibilities offered by Gradle: task.dependsOn and task.doFirst, but none works. The latter appears to be ignored, while dependsOn does add the dependency, but too late in the dependency chain. Running ./gradlew tasks --all prints this



:assembleRelease - Assembles all Release builds [libs:ActionBarSherlock:bundleRelease, libs:DataDroid:bundleRelease, libs:SlidingMenu:bundleRelease]
:compileRelease
...
[SEVERAL TASKS]
...
:packageRelease
...
[SEVERAL TASKS]
...
:readPasswordFromInput


The problem is, the keystore password is needed in the task packageRelease


Just as a side note, this works as I want



buildTypes {
release {
def console = System.console()

ext.keystorePassword = console.readLine('\n\n\n> IF building release apk, enter keystore password: ')

debuggable false

signingConfigs.release.storePassword = ext.keystorePassword
signingConfigs.release.keyPassword = ext.keystorePassword

signingConfig signingConfigs.release
}
}


but it asks for the password every single time you use gradlew, no matter if it's a clean or an assemble


Thanks!


EDIT


Thanks to @Intae Kim, here's my build.gradle version 2.0



task readPasswordFromInput << {
def console = System.console()

ext.keystorePassword = console.readLine('\n\n\n> Enter keystore password: ')

android.signingConfigs.release.storePassword = ext.keystorePassword
android.signingConfigs.release.keyPassword = ext.keystorePassword
}

tasks.whenTaskAdded { task ->
if (task.name == 'validateReleaseSigning') {
task.dependsOn readPasswordFromInput
}
}

apply plugin: 'android'


Then, the buildTypes



release {
debuggable false

signingConfig signingConfigs.release

runProguard true
proguardFile 'my-file.txt'
}


Gradle executes correctly, but it only generates a release-unsigned.apk



Read more

stackoverflow.comm



[android help] Handle messages and errors from operating system


Handle messages and errors from operating system



I wonder if can handle messages from OS.


For example: If i try to open PDF file and is fail , i get from OS mesage that i can't open this file.


Is it possibility to catch this message and replace with my message?



Read more

stackoverflow.comm



Friday, July 26, 2013

[General] How to update a rooted device?


How to update a rooted device?



I'd like to stay away from flashing, so tell me if this works: Backup my Nexus 7, un-root and re-lock it, update to Android 4.3, re-root and unlock, and then restore from that backup. Would that work? Is there a program that roots 4.3 yet? The Nexus Root Toolkit doesn't seem to have the option, and it's what I used before. Also, would I even be able to use the 4.2.2 backup on 4.3, or would that mess it up? Sorry if these questions are simple to answer or stupid, I'm still kind of new at this entire rooting thing. Thanks!



Read more

forum.xda-developers.com



[General] Quoting from the Kindle app on the Nexus 7


Quoting from the Kindle app on the Nexus 7



I've looked! The God's know I've looked, but I cannot find anywhere which gives me clear instruction on how to quote from the Kindle app on my Nexus 7. Can anyone please help me out here? Thank you.



Read more

forum.xda-developers.com



[General] Google Account sync over wifi only


Google Account sync over wifi only



Hello Everyone,

I just got my first android phone, a samsung galaxy s4 and love it. I have been able to set it up as I want for the most part. One thing I cant figure out though, how do you set google account sync to only sync over wifi? I know you can go into the data section and choose which apps can update over wifi, but I don't see one for google account sync. Is it called google services or something? In the google plus I was able to set it to update photos and videos over wifi, but what about the calendar, app data, drive etc.?

Thanks for the help!
Pat



Read more

forum.xda-developers.com



[General] HTC One Charging Port


HTC One Charging Port



It would need to be professionally done. The HTC one us encased in one whole shell, and removing that would be a problem in itself.

Not to mention that the hardware components are most likely soldered to the motherboard, in a very precise fashion. To replace hardware with that much precision, you would need some fancy and expensive equipment.

I highly recommend not doing it yourself and just send it in to HTC to have it repaired. The one should have come with at least a one year warranty (I'm unsure don't have device). That is if you don't mind being without a phone for at least a week.

However I have seen cases where manufacturers would provide temp phones, if the repair takes long enough to warrant loaning one out.

Sent from my paranoid s3...



Read more

forum.xda-developers.com



[General] Can I use JB Weld on a cracked touch screen?


Can I use JB Weld on a cracked touch screen?



My son dropped his Nexus and of course it cracked the glass. The crack is on the side not affecting the view of the face at all and it has a couple of chipped pieces. I was just going to try filling the area with something like silicone, JB Weld, or auto windshield repair.

I'm wondering if anyone might know what I can use that will not interfere with the touch screen. I'm thinking that silicone might be too much like "skin" touching that it might not work. Would like others' opinions.



Read more

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