[android-developers] Don't recieve Wi-Fi connection change intent when device screen is blank

2012-10-26 Thread draf...@gmail.com
I currently listen for changes in the Wi-Fi in my Android application and 
for the most part it works OK, however when the user has there device is 
idle/sleep mode, as in when the screen is blank. If they walk into a Wi-Fi 
area and automatically connect I don't get the intent until the user has 
turned on the screen. This is not good and leads to complaints about my 
application. Can anyone help with why I don't get the intent until the 
screen wakes up?

Here is my code:

BroadcastReciever:

public class WifiReciever extends BroadcastReceiver{

@Override
public void onReceive(Context arg0, Intent arg1) {

String action = arg1.getAction();

if (!action.equals(ConnectivityManager.CONNECTIVITY_ACTION)){
return;
}

if (!noConnectivity)
{
if (aNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI)
{
//Handle connected case
Log.e(E, GOT CONNECTION); 
}
}
else
{
if (aNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI)
{
//Handle disconnected case
Log.e(E, LOST CONNECTION);
}
}

}

If a running Service I have that as a variable:

WifiReciever mConnectionReceiver;


And I start and stop the receiver in the service with the following calls:

private synchronized void startMonitoringConnection()
{   
IntentFilter aFilter = new 
IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);   
registerReceiver(mConnectionReceiver, aFilter);
}

private synchronized void stopMonitoringConnection()
{ 
unregisterReceiver(mConnectionReceiver);
}

I call a WakeLock to make sure that I am getting CPU time like this:

pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, CicCPULock);
wl.acquire();

However even with all that I never receive the Connectivity changed intent 
if the screen is blank, it works 100% of the time when the screen is on bit 
if I a user walks into a Wi-Fi are and connects when the screen is blank I 
fail to get the intent, is anyone aware of something I am missing?


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Android - use multiple Activities within a TabActivity what's the solution?

2011-10-27 Thread draf...@gmail.com
I currently have a TabActivity which has 4 tabs, within one of the
tab's I want to be able to move forward and back between 4 different
Activities.

However if I try to start a new Activity now it removes the TabActivty
and starts a whole new Activity with no tab bars.

I have read about using view groups but that this is not best practice
and also about using a view flipper but this doesn't seem to let me
switch between different Activities only change the views within the
Activity. I can't implement back functionality for exa,ple.

Can anyone point me in the right direction as to what I should be
looking for as a solution to this?

Some more information:

Within the TabActivity my first screen will be a ListView that
contains 4 rows, then selecting one of these will in turn load another
ListView with 2 rows again within the TabActivity and then the 3rd
screen will just contain some text depending on which option the user
chose again within the Tab Activity.

Is a ViewFlipper the best solution here? It seems to me that it will
require a lot of coding within one Activity if I use the ViewFlipper?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Strange behavior after signing build with release keystore

2011-07-29 Thread draf...@gmail.com
Having some really strange bugs with my Android application at the
minute, it I run it from Eclipse it runs fine, pretty much perfect.

It contains a login screen that I can access and get to my main screen
fine when running through Eclipse. When I press the home key and
return to my application it returns to the last position (Activity)
the application was in.

However when I release sign a build and deploy it on the device it has
different behavior,after going through the login screen when I press
home and then return to the application the login screen always
appears.

Code is identical in both builds, only difference is one is signed
with the default debug keystore while the other is signed with my own
release keystore.

Has anyone come across this? Its really confusing!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Eclipse wont regenerate files since downloading the 2.3 SDK

2011-04-19 Thread draf...@gmail.com
I done this and the output simply says Refreshing resource folders
and thats it, there is nothing else.

None of these other workarounds work for me.

On Mar 15, 10:48 pm, Xavier Ducrohet x...@android.com wrote:
 Can you enable verbose build output (in the Eclipse preferences under
 Android  Build), force a compile and see what's dumped in the console
 view?



 On Tue, Mar 15, 2011 at 6:46 AM, Donal Rafferty draf...@gmail.com wrote:
  Bit of an update on this, I'm still stuck on it and have noticed some
  curious issues.

  My project was started back in 1.5 SDK so my resources only had the one
  drawables folder so I created the three -mdpi,-ldpi, -hdpi folders and put
  my drawables in -mdpi.

  I was hoping this would be it but it wasn't R.java still wont regenerate.

  Is there anything I need in my manifest for the new folders or anything that
  needs to be changed like that for the new project setup?

  Also I've noticed if I create a new project and copy over just my Resources
  and build the R.java file generates fine and I can then copy it back into my
  proper project and it works by just matching up the package.
  However if I create a new project and add the resources and then also my
  source files then R.java wont generate and neither will any of my .aidl
  files.

  Which seems really strange to me, has anyone got any ideas taking into
  account the new info as to what could be happening?

  On Fri, Mar 11, 2011 at 4:19 AM, 曾少彬 forever_ho...@hotmail.com wrote:

  Hi,

  I met a similar situation, and it was fixed by removing import
  android.R;, though I really don't know why android.R was imported.

  With android.R, java files won't be able to read local resources
  properly.  I'm not sure if you're meeting the same thing..

  Best Regards!

   Date: Thu, 10 Mar 2011 20:00:13 -0800
   Subject: [android-developers] Re: Eclipse wont regenerate files since
   downloading the 2.3 SDK
   From: zvasv...@gmail.com
   To: android-developers@googlegroups.com

   Yes, this is exactly what I have to do. I don't think it's anything
   on our side of things, but who knows.

   On Mar 11, 9:51 am, Ed Burnette ed.burne...@gmail.com wrote:
Sometimes I have to edit something innocuous in the xml file and in
a .java file and save it (with build automatically set) to get a clean
build. Project  Clean usually works but when it doesn't, the modify-
and-save trick usually works. Changing the Android build target
temporarily might jostle something loose too. I really wish all the
little oddities like this could be ironed out but I have no time to
try and fix it myself.

   --
   You received this message because you are subscribed to the Google
   Groups Android Developers group.
   To post to this group, send email to android-developers@googlegroups.com
   To unsubscribe from this group, send email to
   android-developers+unsubscr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 --
 Xavier Ducrohet
 Android SDK Tech Lead
 Google Inc.http://developer.android.com|http://tools.android.com

 Please do not send me questions directly. Thanks!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Eclipse wont regenerate files since downloading the 2.3 SDK

2011-03-09 Thread draf...@gmail.com
I have recently downloaded the add on to Eclipse for the 2.3 SDK. My
minSDK is 2.1update-1.

Previously I only had up to the 2.2 SDK and I could change my XML
files and drawables without hassle and the generated R.java file would
regenerate properly. The same if I changed my aidl files, the stubs
would regenerate properly.

However since the upgrade to 2.3 SDK I cant change or add any XML
files or drawables or aidl files as they wont regenerate causing all
sorts of issues.

I have googled and tried all sorts of suggestions such as:

Using clean.
Deleting the gen files and rebuilding (Just leaves an empty Gen
folder)
Using non automatic build
Using the new Formating parameter in Strings.xml

However none of them work.

Is there something I've missed that I have to do to get the
regeneration working for 2.3 SDK?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Trouble with loud speaker off on Galaxy S

2010-11-25 Thread draf...@gmail.com
Has anyone else experienced this on the Samsung Galaxy S?

When I use the folowing to turn the Loudspeaker on it works fine:

audioManager.setSpeakerphoneOn(true);

But when I try the opposite to turn it off:

audioManager.setSpeakerphoneOn(false);

The Loudspeaker stays on and audio is played via that instead of the
ear piece on the device.

The above works on the Nexus One and HTC Hero, just got a Samsung
Galaxy the other day and it doesn't work, has anyone else encountered
the issue and perhaps know why it is happening and if there is a work
around?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Android intent filter for SMS and call?

2010-11-01 Thread draf...@gmail.com
I am trying to register my Activity so that it can be used by the
Activity chooser/picker allowing a user to choose whether or not to
select my application/Activity to complete what they are trying to do.

I want to provide the option for the user to be able to select my
application when they want to send an SMS message and when they want
to place an outgoing call, to try to achieve this I added the
following pieces of code within my Activity tags in my manifest:

intent-filter
action android:name=android.intent.action.SENDTO /
category android:name=android.intent.category.DEFAULT /
data android:mimeType=text/plain /
/intent-filter

intent-filter
action android:name=android.intent.action.NEW_OUTGOING_CALL /
category android:name=android.intent.category.DEFAULT /
/intent-filter

However the Activity chooser never appears and the native apps are
used without providing a choice to the user. Can anyone see where I am
going wrong?

EDIT:

I have figured out I need to add

data android:scheme=sms /
data android:scheme=smsto /

for the SMS message but what do I use for the outgoing call?

EDIT 2:

I have tried the following for the outgoing call:

 intent-filter
 action android:name=android.intent.action.VIEW /
 action android:name=android.intent.action.DIAL /
 category android:name=android.intent.category.DEFAULT /
 category android:name=android.intent.category.BROWSABLE /
 data android:scheme=tel /
 /intent-filter

But again with no luck, has this been blocked from 1.6 on?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Get soft keyboard to automatically pop up when a dialog is displayed?

2010-10-22 Thread draf...@gmail.com
I currently pop up a custom dialog with an EditText in it. Currently
the keyboard will only pop up when the user clicks into the
EditText.

Is it possible to get the keyboard to pop up for the EditText as soon
as the Dialog loads?

I have tried:

editText = (EditText) findViewById(R.id.EditTextd);
editText.setFocusable(true);
editText.requestFocus();

But it hasn't worked.

Has anyone any ideas?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Display a numeric keypad on activity without an input area

2010-10-21 Thread draf...@gmail.com
I use the following code to pop up the soft input keyboard in my
Activity

---

InputMethodManager imm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
imm.getInputMethodList();

imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

---

This displays the alphabetic keyboard.

But I want to display the numeric keyboard.

Please note I know that using setInputType() works when used with an
Edittext or a TextView but I want to be able to display the keyboard
without an input area such as an EditText and simply listen to the key
presses on the keyboard.

Can anyone confirm whether this is possible and if so how can it be
achieved?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Listen for key presses on Numeric keypad?

2010-10-21 Thread draf...@gmail.com
I use the following code to listen for the key presses of 0 - 9 from
the soft input keyboard on Android:

---

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)  {

if(keyCode == KeyEvent.KEYCODE_0)
{
return super.onKeyDown(keyCode, event);
}

if(keyCode == KeyEvent.KEYCODE_1)
{
return super.onKeyDown(keyCode, event);
}

if(keyCode == KeyEvent.KEYCODE_2)
{
return super.onKeyDown(keyCode, event);
}

if(keyCode == KeyEvent.KEYCODE_3)
{
return super.onKeyDown(keyCode, event);
}

if(keyCode == KeyEvent.KEYCODE_4)
{
return super.onKeyDown(keyCode, event);
}

if(keyCode == KeyEvent.KEYCODE_5)
{
return super.onKeyDown(keyCode, event);
}

if(keyCode == KeyEvent.KEYCODE_6)
{
return super.onKeyDown(keyCode, event);
}

if(keyCode == KeyEvent.KEYCODE_7)
{
return super.onKeyDown(keyCode, event);
}

if(keyCode == KeyEvent.KEYCODE_8)
{
return super.onKeyDown(keyCode, event);
}

if(keyCode == KeyEvent.KEYCODE_9)
{
Log.d(Keycode, Got KeyCode 9);
return super.onKeyDown(keyCode, event);
}

return true;
}

---

The code works when i display the soft input keyboard in the following
mode:

http://i.imgur.com/Snasz.png

However it does **not** work when I display the soft input keyboard in
the following mode:

 http://i.imgur.com/wf0Kt.png

Why is this?



-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Unusual Android Error

2010-10-12 Thread draf...@gmail.com


I have an Activity that uses a ListView to simply display a list of
options for a user to select and when they select an option they are
taken to a new Activity.

However on occasion the Activity with the options freezes when I try
to select one of the options, I get the ANR and in the log cat the
following error is displayed:

java.lang.RuntimeException: Performing pause of activity that is not
resumed:Activity

Does anyone know what this error means and how to diagnose it?

A search brings up very little.

Does anyone know what may be causing the error?

I can post the code on request

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] CheckBoxPreference default value

2010-10-11 Thread draf...@gmail.com


I have the following XML code for my CheckBoxPreference:

 CheckBoxPreference
android:key=pref_boot_startup
android:title=Auto start
android:defaultValue=true
/

But when I retrieve the preference in code the value is false.

 sharedPreferences =
PreferenceManager.getDefaultSharedPreferences(this);
 boolean autoStart = sharedPreferences.getBoolean(pref_boot_startup,
true);

My autoStart variable returns false.

Is there a specific reason for this? Am I missing a step to set the
default value to true?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] How to decrypt an XML file?

2010-09-24 Thread draf...@gmail.com
 0  down vote  favorite


I am trying to to download and decrypt an encrypted XML file.

I have implemented the download part and have tested with an
unencrypted file and it works fine.

However I now need to be able to download an XML file that has been
encrypted using AES and the key 

So I am only concerned with decryption as the encryption on the XML
file is already done.

Here is my code so far:

 public NodeList getXMLDoc(){
URL url;
NodeList nl = null;

try{
String xmlFeed = context.getString(R.string.xml_feed);
try {
url = new URL(xmlFeed);
URLConnection urlConnection;
urlConnection = url.openConnection();
HttpURLConnection httpConnection = (HttpURLConnection)
urlConnection;
int responseCode = httpConnection.getResponseCode();

if(responseCode == HttpURLConnection.HTTP_OK){

String bytes = toHex();
SecretKeySpec skeySpec = new
SecretKeySpec(toByte(bytes), AES);
try {
c.init(Cipher.DECRYPT_MODE, skeySpec);
//c.doFinal();
} catch (InvalidKeyException e) {
e.printStackTrace();
}
InputStream in = httpConnection.getInputStream();
CipherInputStream cis = new CipherInputStream(in,
c);
DocumentBuilderFactory dbf;
dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();

Document dom = db.parse(cis);

Element docEle = dom.getDocumentElement();

nl = docEle.getElementsByTagName(TAG_CHAR);

}
}
catch (MalformedURLException e) {

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

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

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

e.printStackTrace();
}
}
finally{

}
return nl;
}

At the minute I am trying to decrypt the whole file using
CipherInputStream is this the correct approach?

My code above gives me the following exception:

WARN/System.err(5274): java.io.IOException: last block incomplete in
decryption

Is this a setup error or what might be causing this error?

Are there any tutorials on how to decrypt an XML file in Android/Java?

Am I going in the right direction as to how to decrypt the file or is
my code completely wrong?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] how to get specific preference in Java code from an XML preferences file?

2010-09-23 Thread draf...@gmail.com


I have the following code in my application in res/xml/
preferences.xml:

PreferenceScreen xmlns:android=http://schemas.android.com/apk/res/
android
PreferenceCategory android:title=Wi-Fi settings


   EditTextPreference
android:key=pref_voice_threshold_top
android:title=@string/title_pref_voicetopthreshold
android:dialogTitle=@string/
dialog_title_pref_voicetopthreshold
android:defaultValue=20
android:inputType=number/

/PreferenceCategory

/PreferenceScreen

And I was wondering is it possible for me to then use this preference
in code so I can update it via downloading an xml file?

So I currently display the above preference in a PreferenceActivity,
which works fine, however I want to be able to update the setting by
downloading a new setting every week from the internet.

So my question is how do I open this preference in code and set its
value to the new downloaded value?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] AsyncTask doesn't run sometimes despite state returning RUNNING?

2010-09-10 Thread draf...@gmail.com
In my application I use an AsyncTask on start up of my Activity to
fetch the ringtone of a particular contact.

It works normally but I have noticed that if the application is
stopped twice before the AsyncTask gets to the doInBackground method
then when the Activity starts again the AsyncTask fails to run
properly, only getting to the onPreExecute() method.

Here is my code:

The AsyncTask itself:

---

private class SelectRingtoneTask extends AsyncTaskString, Void,
Void {

  // can use UI thread here
  protected void onPreExecute() {
  Log.d(cda, Into selectRingToneTask - 
onPreExecute() -  +
selectRingtoneFinished);
  }

  // automatically done on worker thread (separate from UI
thread)
  protected Void doInBackground(final String... args) {
  Log.d(cda, Into selectRingToneTask - 
!!!);
 getRingTone();
 return null;
  }

  // can use UI thread here
  protected void onPostExecute(final Void unused) {
   selectRingtoneFinished = true;
   Log.d(cda, Into selectRingToneTask - onPostExecute - 
 +
selectRingtoneFinished);
  }
   }

---

Where I call the AsyncTask on start up:

---

if(srtt == null){
srtt = new SelectRingtoneTask();
Log.d(cda, RingTone -  + srtt.getStatus());
}
srtt.execute();

---

The problem occur's when I start the activity and close the Activity
before the AsyncTask finishes, if this happens once, it seems to be
fine but after it happens a second time the AsyncTask will only ever
get to the onPreExecute() method and will never complete again until
the application is force stopped and restarted.

Has anybody got any idea why this would be happening?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] how to make sure my Service is restarted?

2010-08-31 Thread draf...@gmail.com
 0  down vote  favorite


I have an Android application with a background running Service.

When the Service crashes or gets killed by Android I can see that
Android tries to restart it again.

However the Service never actually restarts, I can see Android
scheduling the restart but it new actually happens.

My code is as follows:

--

@Override
public void onCreate() {
String ns = Context.NOTIFICATION_SERVICE;
mNotificationManager = (NotificationManager) getSystemService(ns);
mTelephonyManager =
(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
audio_service = (AudioManager)
getSystemService(Context.AUDIO_SERVICE);


}

// This is the old onStart method that will be called on the pre-2.0
// platform.  On 2.0 or later we override onStartCommand() so this
// method will not be called.
@Override
public void onStart(Intent intent, int startId) {
handleCommand(intent);
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
handleCommand(intent);
// We want this service to continue running until it is explicitly
// stopped, so return sticky.
return START_STICKY;
}

 void handleCommand(Intent intent) {

running = true;
mTelephonyManager.listen(new IncomingListener(),
PhoneStateListener.LISTEN_CALL_STATE);

}

--

Is there something missing in my code to allow the Service be
restarted?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] onBackPressed() not working

2010-08-24 Thread draf...@gmail.com
I have an application building against Android 2.1 and I want to
override the back button.

I have followed the example here:

http://android-developers.blogspot.com/2009_12_01_archive.html

And my code is as follows:

---

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)  {
if (Integer.parseInt(android.os.Build.VERSION.SDK)  5
 keyCode == KeyEvent.KEYCODE_BACK
 event.getRepeatCount() == 0) {
Log.d(CDA, onKeyDown Called);
onBackPressed();
}

return true;
}

@Override
public void onBackPressed() {
Log.d(CDA, onBackPressed Called);
Intent setIntent = new Intent(Intent.ACTION_MAIN);
setIntent.addCategory(Intent.CATEGORY_HOME);
setIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(setIntent);

return;
}

---

It works on pre 2.x devices but doesn't work on a Hero with 2.1
update-1 and a Nexus One with 2.2.

Is there somwthing I am missing from the example? Or can anyone point
out why it isn't working?

I dont even get the button pressed in the logcat.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Slider devices cause Activities to reset…

2010-08-20 Thread draf...@gmail.com

While testing on Android 1.6 using a G1 I have noticed that when I
slide out the keyboard it kills the activity and recreates it even
though I have set my activity to only display in portrait mode.

Same happens when I push the keyboard back in.

I get onSaveInstance, onDestroy called, then onCreate, onResume,
OnrestoreInstance...

I understand why this is done when the display is being switched to
landscape view but why does this happen when I specifically dont want
my activity to switch view, its essentially killing and restarting the
activity for no reason.

Is it the same on 2.x devices?

Is there something I'm missing to stop it happening?

Can anyone explain if there is any point to it?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Slider devices cause Activi ties to reset…

2010-08-20 Thread draf...@gmail.com
Ah i missedunderstood what that meant! Thanks very much.

How do I use more than one variable though?

I have tried it as follows:

android:configChanges=[keyboard, keyboardHidden, orientation]

But it wont compile for me

I get:

AndroidManifest.xml: Open quote is expected for attribute
android:configChanges associated with an  element type  activity.
Error in an XML file: aborting build.

in the console.

On Aug 20, 2:28 pm, RichardC richard.crit...@googlemail.com wrote:
 Read about the mainfest activity setting 
 android:configChangeshttp://developer.android.com/guide/topics/manifest/activity-element.htmlhttp://developer.android.com/guide/topics/manifest/activity-element.h...

 On Aug 20, 2:17 pm, draf...@gmail.com draf...@gmail.com wrote:

  While testing on Android 1.6 using a G1 I have noticed that when I
  slide out the keyboard it kills the activity and recreates it even
  though I have set my activity to only display in portrait mode.

  Same happens when I push the keyboard back in.

  I get onSaveInstance, onDestroy called, then onCreate, onResume,
  OnrestoreInstance...

  I understand why this is done when the display is being switched to
  landscape view but why does this happen when I specifically dont want
  my activity to switch view, its essentially killing and restarting the
  activity for no reason.

  Is it the same on 2.x devices?

  Is there something I'm missing to stop it happening?

  Can anyone explain if there is any point to it?



-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Slider devices cause Activi ties to reset…

2010-08-20 Thread draf...@gmail.com
NeverMind, I got it!

On Aug 20, 2:28 pm, RichardC richard.crit...@googlemail.com wrote:
 Read about the mainfest activity setting 
 android:configChangeshttp://developer.android.com/guide/topics/manifest/activity-element.htmlhttp://developer.android.com/guide/topics/manifest/activity-element.h...

 On Aug 20, 2:17 pm, draf...@gmail.com draf...@gmail.com wrote:

  While testing on Android 1.6 using a G1 I have noticed that when I
  slide out the keyboard it kills the activity and recreates it even
  though I have set my activity to only display in portrait mode.

  Same happens when I push the keyboard back in.

  I get onSaveInstance, onDestroy called, then onCreate, onResume,
  OnrestoreInstance...

  I understand why this is done when the display is being switched to
  landscape view but why does this happen when I specifically dont want
  my activity to switch view, its essentially killing and restarting the
  activity for no reason.

  Is it the same on 2.x devices?

  Is there something I'm missing to stop it happening?

  Can anyone explain if there is any point to it?



-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Key Dispatching Timed Out

2010-08-12 Thread draf...@gmail.com
In my Android application I am getting a very strange crash, when I
press a button (Image) on my UI the entire application freezes and
after a couple of seconds I getthe dreaded force close dialog
appearing.

Here is what gets printed in the log:

---


WARN/WindowManager(88): Key dispatching timed out sending to
package name/Activity
WARN/WindowManager(88): Dispatch state: {{KeyEvent{action=1 code=5
repeat=0 meta=0 scancode=231 mFlags=8} to Window{432bafa0
com.android.launcher/com.android.launcher.Launcher paused=false} @
1281611789339 lw=Window{432bafa0 com.android.launcher/
com.android.launcher.Launcher paused=false}
lb=android.os.binderpr...@431ee8e8 fin=false gfw=true ed=true tts=0
wf=false fp=false mcf=Window{4335fc58 package name/Activity
paused=false}}}
WARN/WindowManager(88): Current state:  {{null to Window{4335fc58
package name/Activity paused=false} @ 1281611821193 lw=Window{4335fc58
package name/Activity paused=false} lb=android.os.binderpr...@434c9bd0
fin=false gfw=true ed=true tts=0 wf=false fp=false mcf=Window{4335fc58
package name/Activity paused=false}}}
INFO/ActivityManager(88): ANR in process: package name (last in
package name)
INFO/ActivityManager(88): Annotation: keyDispatchingTimedOut
INFO/ActivityManager(88): CPU usage:
INFO/ActivityManager(88): Load: 5.18 / 5.1 / 4.75
INFO/ActivityManager(88): CPU usage from 7373ms to 1195ms ago:
INFO/ActivityManager(88):   package name: 6% = 1% user + 5%
kernel / faults: 7 minor
INFO/ActivityManager(88):   system_server: 5% = 4% user + 1%
kernel / faults: 27 minor
INFO/ActivityManager(88):   tiwlan_wifi_wq: 3% = 0% user + 3%
kernel
INFO/ActivityManager(88):   mediaserver: 0% = 0% user + 0% kernel
INFO/ActivityManager(88):   logcat: 0% = 0% user + 0% kernel
INFO/ActivityManager(88): TOTAL: 12% = 5% user + 6% kernel + 0%
softirq
INFO/ActivityManager(88): Removing old ANR trace file from /data/
anr/traces.txt
INFO/Process(88): Sending signal. PID: 1812 SIG: 3
INFO/dalvikvm(1812): threadid=7: reacting to signal 3
INFO/dalvikvm(1812): Wrote stack trace to '/data/anr/traces.txt'

---

This is the code for the Button (Image):

---

findViewById(R.id.endcallimage).setOnClickListener(new
OnClickListener() {
public void onClick(View v) {
mNotificationManager.cancel(2);

Log.d(Handler, Endcallimage 
pressed);

if(callConnected)
elapsedTimeBeforePause = 
SystemClock.elapsedRealtime()
- stopWatch.getBase();

try {

serviceBinder.endCall(lineId);
} catch 
(RemoteException e) {

e.printStackTrace();
}
dispatchKeyEvent(new
KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.FLAG_SOFT_KEYBOARD));
dispatchKeyEvent(new
KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK));
}
});

---

If I comment the following out the pressing of the button (image)
doesn't cause the crash:

---

try {
  serviceBinder.endCall(lineId);
} catch (RemoteException e) {
  e.printStackTrace();
}

---

The above code calls down through several levels of the app and into
the native layer (NDK), could the call passing through several objects
be leading to the force close? It seems unlikely as several other
buttons do the same without issue.

How about the native layer? Could some code I've built with the NDK be
causing the issue?

Any other ideas as to what the cause of the issue might be?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] How do I capture and loop video to the screen?

2010-08-09 Thread draf...@gmail.com


I was wondering if anyone knows of a tutorial explaining how to
capture the video from the camera on an Android device and then
display the video in real time on the screen?

I have looked up MediaRecorder, MediaPlayer, Videoview but they all
seem concerned with recording audio/video to a file or playing audio/
video from a file or a URL.

I simply want to be able to take the data from what the camera is
seeing and display it on the screen.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Android Market Licensing: Now Available!

2010-07-28 Thread draf...@gmail.com
Really required in the Republic of Ireland too, Android devices are
getting quite popular here and the time has come to open the paid
market

On Jul 27, 9:24 pm, Sebastian Rodriguez srodrig...@gmail.com wrote:
 I agree with Anton Persson. When will Google realize that opening the paid
 market to all the other countries is crucial for the market environment :(
 We don't have access to them here in Singapore either.

 But this is a major step already, let's hope for even better!

 Seb

 On 28 July 2010 04:19, Kaj Bjurman kaj.bjur...@gmail.com wrote:



  I saw that entry, and have a question.

  What will happen if the user doesn't have network connectivity? Many
  users turn of data traffic when they travel to other countries, but
  the probably still want to use the licensed applications.

  On 27 Juli, 19:55, Trevor Johns trevorjo...@google.com wrote:
   Android fans,
   For those of you who haven't already heard through our blog, we've
   just launched the Android Market licensing service:

  http://android-developers.blogspot.com/2010/07/licensing-service-for-...

   From the above blog post:

   This simple and free service provides a secure mechanism to manage
   access to all Android Market paid applications targeting Android 1.5
   or higher. At run time, with the inclusion of a set of libraries
   provided by us, your application can query the Android Market
   licensing server to determine the license status of your users. It
   returns information on whether your users are authorized to use the
   app based on stored sales records.

   Developer documentation is available here:

  http://developer.android.com/guide/publishing/licensing.html

   Happy coding!

   --
   Trevor Johns
   Google Developer Programs, Androidhttp://developer.android.com

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 --
 Sebastien Rodriguez

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] How to change target build on Android project?

2010-07-27 Thread draf...@gmail.com
I currently have an Android project in Eclipse.

I created it with a target build of 1.5 (sdk 3).

Now I want to change it so that it has a minSdk of 3 and targetSdk of
8.

To do this I see that I must build against the newest SDK (2.2)

To do this in Eclipse I right click on my project, go to properties,
click on Android and change the project build target to Android 2.2
and click apply and then ok.

However this appears to have no affect and when I try it again the
target build is set back at Android 1.5.

Am I missing a step or something?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] How to code ContactsContract so that it runs in 2.2 and doesn't crash 1.5?

2010-07-27 Thread draf...@gmail.com
I have the following piece of code in my Android application that
looks up a contacts ID, I have just changed the target from 1.5 to 2.2
but with a min SDK of 3 (1.5) so that I can use the ContactsContract
Uri in 2.2 and the People Uri in 1.5.

However the code leads to the following error when run on 1.5 devices:

07-27 15:02:53.382: WARN/dalvikvm(12656): VFY: unable to resolve
static field 25 (CONTENT_URI) in Landroid/provider/ContactsContract
$Contacts;

---

From google I have garnered that I need to use reflection in this case
to allow the application run on both versions of Android?

I have seen example's of how to use reflection to use methods of
multiple/different versions but how can I use it in mycase where I
want to use the ContactsContract Uri?

Here is my code:

---


findViewById(R.id.contactimage).setOnClickListener(new
OnClickListener() {
public void onClick(View v) {

String sdk = android.os.Build.VERSION.SDK;
Uri contactUri;
Log.d(CDA, Contact ID Button pressed =  +
contactId);
if(sdk.equals(8)){
contactUri = ContentUris.withAppendedId
(ContactsContract.Contacts.CONTENT_URI, 
contactId);

Intent intent = new 
Intent(Intent.ACTION_VIEW,
contactUri);
startActivity(intent);

}
else{
contactUri = ContentUris.withAppendedId
(People.CONTENT_URI, contactId);

Intent intent = new Intent(Intent.ACTION_VIEW,
contactUri);
startActivity(intent);
}

dispatchKeyEvent(new
KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.FLAG_SOFT_KEYBOARD));
dispatchKeyEvent(new 
KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_BACK));
}
});

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Android - Java Observer not working

2010-07-14 Thread draf...@gmail.com
I am having some trouble with implementing my own observer in Java on
the Android platform.

I have created a class call NetworkPathJni that uses an Observer
interface class called NetworkPathJniObserver to notify other objects
of changes.

Here is the code for NetworkPathJni.java

---

public class NetworkPathJni {

NetworkPathJniObserver networkPathJniObserver;

  public NetworkPathJni(NetworkPathJniObserver aObserver){

networkPathJniObserver = aObserver;
Log.d(Phone, NetworkPathJni Created );

  }

  public void NetworkPathStateChanged(int aAvailabilityState){
  Log.d(Phone, NetworkPathStateChanged new state =  +
aAvailabilityState );
  TAvailabilityState availabilityState =
intToAvailability(aAvailabilityState);
  Log.d(Phone, Is SipNetworkPath alive? +
networkPathJniObserver.isAlive());
 
networkPathJniObserver.NetworkPathStateChanged(availabilityState);
  Log.d(Phone, NetworkPathStateChanged end );
  Log.d(Phone, Is SipNetworkPath alive? (2) +
networkPathJniObserver.isAlive());

  }

---

And here is the code for the observer

---

public interface NetworkPathJniObserver {

void NetworkPathStateChanged(TAvailabilityState aAvailabilityState);

boolean isAlive();
}

---

The observer is implemented as follows in a class called
SipNetworkPath

---

public class SipNetworkPath implements NetworkPathInterface,
NetworkPathJniObserver{

NetworkPathObserverInterface observer;
NetworkPathJni networkPathJni;

public SipNetworkPath(NetworkPathObserverInterface aObserver){
domainType = aDomainType;
observer = aObserver;
networkPathJni = new NetworkPathJni(this);
Log.d(Phone, SipNetworkPath created );
}

//NetworkPathJniObserver

@Override
public void NetworkPathStateChanged(TAvailabilityState
availabilityState) {
Log.d(SipNetworkPath, SipNetworkPath - Do networkpathstate
changed!);
}

@Override
public boolean isAlive() {
return true;

}

---

And SipNetworkPath is instanciated as follows

---

public class WifiNetworkPath extends SipNetworkPath{

public WifiNetworkPath(NetworkPathObserverInterface aObserver) {
super(aObserver);
}

---

The logging shows that both NetworkPathJni and SipNetworkPath get
created and that NetworkPathStateChanged(int aAvailabilityState) is
called.

Within that method all the logging comes back but the method does not
get called in the observer and I get false when I ask Is
SipNetworkPath alive? in the logging.

Is the observer class losing reference or something or is there a
mistake in my way of doing this? Does Android kill off objects that
are not part of an Activity or a Service instantly or something along
thoese lines that might be causing the problem?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] How to create Multiple instances of an Activity From a Service?

2010-07-01 Thread draf...@gmail.com
I was wondering is it possible to create multiple instances of a
single Activity in Android?

I currently start my own inCall screen for a Voip Test by using the
following code: (Used in a Service)

---

 public void initInCallScreen(String pName, String phoneNumber,
int contactID, boolean
callDirection, int lineID){

//starts in callScreen dialog
final Intent myIntent = new Intent(context,
CallDialogActivity.class);
myIntent.putExtra(NAME, pName);
myIntent.putExtra(NUMBER, phoneNumber);
myIntent.putExtra(ID, contactID);
myIntent.putExtra(CALLTYPE, callDirection); //True =
Incoming, False = Outgoing
myIntent.putExtra(LINEID, lineID);
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myIntent);

---

This allows me to start the Activity fine.

However when I call it for a second it just returns to the Activity
already created rather than creating a new Activity and placing it on
the stack.

I would like to be able to create the activity multiple times so that
I have two or 3 Activities on the stack and the user can switch
between them, using Home, Back buttons etc...

Is this possible and if so what am I doing wrong?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] How To Override the “Back” button so it doesn’t Finish() my Activity?

2010-06-29 Thread draf...@gmail.com
I currently have an Activity that when it gets displayed a
Notification will also get displayed in the Notification bar.

This is so that when the User presses home and the Activity gets
pushed to the background they can get back to the Activity via the
Notification.

The problem arises when a User presses the back button, my Activity
gets destroyed but the Notification remains as I want the user to be
able to press back but still be able to get to the Activity via the
Notification. But when a USER tries this I get Null Pointers as its
trying to start a new activity rather than bringing back the old one.

So essentially I want the Back button to act the exact same as the
Home button and here is how I have tried so far:

---


@Override
public boolean onKeyDown(int keyCode, KeyEvent event)  {
if (Integer.parseInt(android.os.Build.VERSION.SDK) 
 5
 keyCode == KeyEvent.KEYCODE_BACK
 event.getRepeatCount() == 0) {
Log.d(CDA, onKeyDown Called);
onBackPressed();
}

return super.onKeyDown(keyCode, event);
}

public void onBackPressed() {
Log.d(CDA, onBackPressed Called);
Intent setIntent = new Intent(Intent.ACTION_MAIN);
setIntent.addCategory(Intent.CATEGORY_HOME);
setIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(setIntent);

return;
}

---

However the above code still seems to allow my Activity to be
destroyed, How can I stop my Activity from being destroyed when the
back button is pressed?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] How to save an object in onSaveInstanceState?

2010-06-18 Thread draf...@gmail.com
I have created a small XML parsing application for Android that
displays information in a listview and then allows a user to click on
the list view and a dialog with further info will pop up.

The problem is that when the screen orientation is changed when a
dialog screen is open I get a null pointer error.

The null pointer occurs on the following line:

---


if(setting.getAddForPublicUserNames() == 1){

---

This line is part of my dialogPrepare method:

---


@Override
public void onPrepareDialog(int id, Dialog dialog) {
  switch(id) {
case (SETTINGS_DIALOG) :

afpunText = ;

if(setting.getAddForPublicUserNames() == 1){
afpunText = Yes;
}
else{
afpunText = No;
}
  String Text = Login Settings:  + \n
   + Password:  + setting.getPassword()  +
\n
   + Server:  + setting.getServerAddress() +
\n
   + Register:  +
setting.getRegistrarAddress() + \n
   + Realm:  + setting.getRealm() + \n
   + Public UserNames:  + afpunText  + \n
   + Preference Settings:  + \n
   + Request VDN:  + 
setting.getRequestVDN() + \n
   + Handover Settings:  + \n
   + Enable Handover:  + 
setting.getEnableHandover() +
\n
   + Hand Over Number:  + 
setting.getHandoverNum() +
\n;

  AlertDialog settingsDialog = (AlertDialog)dialog;
  settingsDialog.setTitle(Auth ID:  + setting.getUserName());

  tv = 
(TextView)settingsDialog.findViewById(R.id.detailsTextView);
  if (tv != null)
tv.setText(Text);

  break;
  }
}


---

So the error is that my variable setting is null after the screen
orientation changes.

I have tried to use the onSaveInstance state methods to fix that as
follows:

---


@Override
public void onSaveInstanceState(Bundle savedInstanceState) {


  for(int i = 0; i  settings.size(); i++){
  savedInstanceState.putString(Username+i,
settings.get(i).getUserName());
  savedInstanceState.putString(Password+i,
settings.get(i).getPassword());
  savedInstanceState.putString(Server+i,
settings.get(i).getServerAddress());
  savedInstanceState.putString(Registrar+i,
settings.get(i).getRegistrarAddress());
  savedInstanceState.putString(Realm+i,
settings.get(i).getRealm());
  savedInstanceState.putInt(PUserNames+i,
settings.get(i).getAddForPublicUserNames());
  savedInstanceState.putString(RequestVDN+i,
settings.get(i).getRequestVDN());
  savedInstanceState.putString(EnableHandOver+i,
settings.get(i).getEnableHandover());
  savedInstanceState.putString(HandOverNum+i,
settings.get(i).getHandoverNum());
  }

  super.onSaveInstanceState(savedInstanceState);
}


---

and

---


@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
  super.onRestoreInstanceState(savedInstanceState);
  //Check to see if this is required

  // Restore UI state from the savedInstanceState.
  // This bundle has also been passed to onCreate.
  for(int i = 0; isettings.size(); i++){
 
settings.get(i).setUserName(savedInstanceState.getString(Username+i));
 
settings.get(i).setPassword(savedInstanceState.getString(Password+i)) ;
 
settings.get(i).setServerAddress(savedInstanceState.getString(Server+i));
 
settings.get(i).setRegistrarAddress(savedInstanceState.getString(Registrar+i));
 
settings.get(i).setRealm(savedInstanceState.getString(Realm+i));
 
settings.get(i).setAddForPublicUserNames(savedInstanceState.getInt(PUserNames+i));
 
settings.get(i).setRequestVDN(savedInstanceState.getString(RequestVDN+i));
 
settings.get(i).setEnableHandover(savedInstanceState.getString(EnableHandOver+i));
 
settings.get(i).setHandoverNum(savedInstanceState.getString(HandOverNum+i));
  }

}

---

However the error still remains, I think I have to save the selected
setting from what was selected from the ListView? But how do I save a
setting object in onSavedInstance?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] A clear, concise tutorial on PreferenceActivity Preferences?

2010-06-01 Thread draf...@gmail.com
I was wondering can anyone direct me to a detailed Preferences
tutorial?

Or provide me with a bit of help here?

I have my preferences saved in preferences.xml as follows:

PreferenceScreen xmlns:android=http://schemas.android.com/apk/res/
android
PreferenceCategory android:title=Wifi Settings

EditTextPreference
android:key=edittext_block_attach_err
android:title=@string/title_edittext_preference
android:summary=@string/summary_edittext_preference
android:dialogTitle=@string/
dialog_title_edittext_preference /

/PreferenceCategory

/PreferenceScreen

I then have a preference activity as follows:

public class WlanSettings extends PreferenceActivity {

SharedPreferences prefs;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

addPreferencesFromResource(R.xml.preferences);
prefs = this.getSharedPreferences(CiceroWlanSettings,
Activity.MODE_PRIVATE);


}

This display's the EditTextPreference fine but how do I then set up a
default preference to be displayed in the dialog box that pops up with
an EditTextPreference?

And How do I save changes that occur in my preference activity to my
preferences?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Does Observer not work in a Android Service?

2010-05-31 Thread draf...@gmail.com
I am using the Observer pattern in my Android application to notify a
running service that some data has changed:

Here is the code outside the Service: (WifiConnectionManager)

---

//Observables
@Override
public void NotifyQCLevelChange(QCLevel newQoSLevel) {
setChanged();
notifyObservers( newQoSLevel );
}


@Override
public void NotifyQCPercentageChange(int percentage) {
setChanged();
notifyObservers( percentage );
}

---

Where the observables get updated within an Observer update method:
(WifiConnectionManager)

---

@Override
public void update(Observable arg0, Object arg) {
if( !iActive )
return;

if( arg0 instanceof WifiMonitor ){
Log.d(WifiConnectionManager, update from WiFiMonitor 
ss=: +
arg.toString());
if( iConnectionState.equals(ConnectionState.IPACTIVE) )
{
int qcPercentage = 
Integer.parseInt(arg.toString());
Log.d(GetActiveQCLevel, GetActiveQCLevel 
called);
QCLevel aConnectionQCLevel = 
GetActiveQCLevel(qcPercentage);


if( 
!aConnectionQCLevel.equals(iConnectionQCLevel) )
{
iConnectionQCLevel = aConnectionQCLevel;
NotifyQCLevelChange(iConnectionQCLevel);
Log.d(NotifyQCLevelChange, 
NotifyQCLevelChange);
}

NotifyQCPercentageChange(qcPercentage);
Log.d(NotifyQCPercentageChange, 
NotifyQCPercentageChange);
}
}

---

And finally the Observer in my service: (WifiService)

---

@Override
public void update(Observable observable, Object data) {

if( observable instanceof WifiConnectionManager  data 
instanceof
QCLevel){

Log.d(WifiConnectionManager, instanceof QCLevel);

}
else if( observable instanceof WifiConnectionManager  data
instanceof Integer){

Log.d(WifiConnectionManager, instanceof Integer);

}
else if( observable instanceof WifiConnectionManager){

Log.d(WifiConnectionManager, instanceof 
WifiConnectionManager);

}

---

From the log I can see that Log.d(GetActiveQCLevel,
GetActiveQCLevel called); 
Log.d(NotifyQCPercentageChange, NotifyQCPercentageChange); get
called but nothing in the update method of the Observer in my service
(WifiService) gets called.

Can anyone see where the problem is or is there a restriction I am not
aware of?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] SendOrderedBroadcast Help

2010-05-31 Thread draf...@gmail.com


I am trying to use a sendOrderedBroadcast in my Android app.

I want to be able to send the Intent from one of my applications to
another and I then want to get data back from the Application that
recieves the Intent, in this case a boolean true or false.

Here is the current code:

Intent i = new Intent();
i.setAction(GlobalData.PROPOSE_IN_DOMAIN_ROAM_INTENT);
i.putExtra(com.testnetworks.QCLEVEL,
aProposedTheoreticalQoSLevel);
sendOrderedBroadcast(i, null, null, null, Activity.RESULT_OK,
null, null);

Is this the correct way to achieve what I want?

If so what do I use as the resultReceiver* parameter? (3rd parameter)

And then how to I recieve data back from the Broadcast?

I have done a quick google and not come up with any examples, any help
or examples greatly appreciated.

*resultReceiver - Your own BroadcastReceiver to treat as the final
receiver of the broadcast.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] How to update a Widget dynamically (Not waiting 30 min for onUpdate to be called)?

2010-05-28 Thread draf...@gmail.com
I am currently learning about widgets in Android.

I want to create a WIFI widget that will display the SSID, the RSSI
(Signal) level.

But I also want to be able to send it data from a service I am running
that calculates the Quality of Sound over wifi.

Here is what I have after some reading and a quick tutorial:

---

public class WlanWidget extends AppWidgetProvider{

RemoteViews remoteViews;
AppWidgetManager appWidgetManager;
ComponentName thisWidget;
WifiManager wifiManager;

public void onUpdate(Context context, AppWidgetManager
appWidgetManager,
int[] appWidgetIds) {
Timer timer = new Timer();
timer.scheduleAtFixedRate(new WlanTimer(context, 
appWidgetManager),
1, 1);

}


private class WlanTimer extends TimerTask{

RemoteViews remoteViews;
AppWidgetManager appWidgetManager;
ComponentName thisWidget;


public WlanTimer(Context context, AppWidgetManager appWidgetManager)
{

this.appWidgetManager = appWidgetManager;
remoteViews = new RemoteViews(context.getPackageName(),
R.layout.widget);
thisWidget = new ComponentName(context, 
WlanWidget.class);
wifiManager =
(WifiManager)context.getSystemService(Context.WIFI_SERVICE);


}

@Override
public void run() {

remoteViews.setTextViewText(R.id.widget_textview,
wifiManager.getConnectionInfo().getSSID());
appWidgetManager.updateAppWidget(thisWidget, 
remoteViews);
}

}

---

The above seems to work ok, it updates the SSID on the widget every 10
seconds.

However what is the most efficent way to get the information from my
service that will be already running to update periodically on my
widget?

Also is there a better approach to updating the the widget rather than
using a timer and timertask? (Avoid polling)

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Get Notified when a new access point is added?

2010-05-26 Thread draf...@gmail.com
I was wondering is it possible to get a notification of when a new
configured network is added to the WifiManager in Android?

I know you can get the current list of configured networks

http://developer.android.com/intl/de/reference/android/net/wifi/WifiManager.html#getConfiguredNetworks%28%29

But is it possible to get notification of when a new one is added?

I dont see anything in the WifiManager that would be helpful.

Has anyone any other ideas? Or insight into how this could be
achieved?


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Issue with WifiManager.calculateSignalLevel(RSSI, 5)

2010-05-20 Thread draf...@gmail.com
I am trying to use the Wifimanager to calculate the Signal Level of
the access points found during a scan.

I am using the following method:

http://developer.android.com/intl/de/reference/android/net/wifi/WifiManager.html#calculateSignalLevel%28int,%20int%29

But it appears to always return the same int no matter what the RSSI
level is.

Here is my code:

---

public int calculateQoS(int aRSSI){

signalLevel = WifiManager.calculateSignalLevel(RSSI, 5);

return signalLevel;

}


---


public void testCalculateQoS(){

Log.d(signal, signal = : 
+ connMonitor.calculateQoS(-44)
+   + connMonitor.calculateQoS(-80)
+   + connMonitor.calculateQoS(-120)
+   + connMonitor.calculateQoS(-20));

}

The logging outputs 1 for all the test cases for calculateQoS(int).

Am I missing something simple here? Why is the SignalLevel always 1?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] How to scan Access Points and select strongest signal?

2010-05-13 Thread draf...@gmail.com
I am currently trying to write a class in Android that will Scan for
access points, calculate which access point has the best signal and
then connect to that access point.


So the application will be able to scan on the move and attach to new
access points on the go.

I have the scanning and calculation of the best signal working.

But when it comes to attaching to the best access point I am having
trouble.

It appears that enableNetwork(netid, othersTrueFalse) is the only
method for attaching to an Access point but this causes problems as
from my Scan Results I am not able to get the id of the access point
with the strongest signal.

This is my code:

---

public void doWifiScan(){

  scanTask = new TimerTask() {
  public void run() {
  handler.post(new Runnable() {
  public void run() {
   sResults = wifiManager.scan(getBaseContext());
   if(sResults!=null)
   Log.d(TIMER, sResults count + sResults.size());
   ScanResult scan =
wifiManager.calculateBestAP(sResults);
   wifiManager.addNewAccessPoint(scan);
   }
   });
}};

t.schedule(scanTask, 3000, 3);
}


---

public ScanResult calculateBestAP(ListScanResult sResults){

 ScanResult bestSignal = null;
for (ScanResult result : sResults) {
  if (bestSignal == null
  || WifiManager.compareSignalLevel(bestSignal.level,
result.level)  0)
bestSignal = result;
}

String message = String.format(%s networks found. %s is the
strongest. %s is the bsid,
sResults.size(), bestSignal.SSID, bestSignal.BSSID);

Log.d(sResult, message);
return bestSignal;
}


---

public void addNewAccessPoint(ScanResult scanResult){

WifiConfiguration wc = new WifiConfiguration();
wc.SSID = '\' + scanResult.SSID + '\';
//wc.preSharedKey  = \password\;
wc.hiddenSSID = true;
wc.status = WifiConfiguration.Status.ENABLED;
wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);

wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);

wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
int res = mainWifi.addNetwork(wc);
Log.d(WifiPreference, add Network returned  + res );
boolean b = mainWifi.enableNetwork(res, false);
Log.d(WifiPreference, enableNetwork returned  + b );

}


---

When I try to use addNewAccessPoint(ScanResult scanResult) it just
adds another AP to the list in the settings application with the same
name as the one with the best signal, so I end up with loads of
duplicates and not actually attaching to them.

Can anyone point me in the direction of a better solution?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] A couple of Rom questions for the experts

2010-05-06 Thread draf...@gmail.com
I have a couple of questions for the Rom developers/experts on here
regarding things that can be done with Android ROM's.

Is a parser Rom upgrade possible? So is it possible to change a small
part of a ROM and then allow users to upgrade their ROM easily?

So can I change a part of a ROM and then a customer can upgrade to the
newer ROM without having to be technically savvy and needing to root
and flash their devices?

Can a change be burnt into a ROM so that when a user selects Restore
Factory Settings that it doesn't remove the upgrade to the ROM?

So essentially I want to know if its possible (with a device
manufacturers permission) to add to a ROM some small additional parts
and then give this new ROM version as a firmware upgrade to the device
so that a user only has to upgrade and not go through the process of
rooting and flashing there device?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Some connectivity questions

2010-05-05 Thread draf...@gmail.com
I have a couple of questions about connectivity on Android, if anyone
has any insight it would be great.

What is the default when an application wants to wirelessly connect?
Is it wlan? And if wlan is switched off or there is no access points
around is it 3g or gprs?

Is a device always ip connected? Or when its disabled from wlan or 3g
does it's lose its ip address?

Is an application, for example the browser only ever connected to one
ip address? Or can it be connected to multiple addresses for each
radio such as gprs or wifi (wlan)?

Can an application decide which connection to open a socket to? For
example can I create an application and decide whether to connect the
socket to the wlan or gprs? Or does the OS decide?

Finally how do native applications handle connectivity? In the same
manner?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Querying the SMS ContentProvider?

2010-04-06 Thread draf...@gmail.com
I currently register a content observer on the following URI
content://sms/ to listen out for incoming and outgoing messages
being sent.

This seems to work ok and I have also tried deleting from the sms
database but I can only delete an entire thread from the following URI
content://sms/conversations/

Here is the code I use for that

Java:
String url = content://sms/;
  Uri uri = Uri.parse(url);
  getContentResolver().registerContentObserver(uri, true, new
MyContentObserver(handler));

}

class MyContentObserver extends ContentObserver {

 public MyContentObserver(Handler handler) {

  super(handler);

 }

@Override public boolean deliverSelfNotifications() {
 return false;
 }

@Override public void onChange(boolean arg0) {
 super.onChange(arg0);

  Log.v(SMS, Notification on SMS observer);

 Message msg = new Message();
msg.obj = xx;

handler.sendMessage(msg);

Uri uriSMSURI = Uri.parse(content://sms/);
Cursor cur = getContentResolver().query(uriSMSURI, null, null,
 null, null);
cur.moveToNext();
String protocol =
cur.getString(cur.getColumnIndex(protocol));
if(protocol == null){
   Log.d(SMS, SMS SEND);
   int threadId =
cur.getInt(cur.getColumnIndex(thread_id));

   Log.d(SMS, SMS SEND ID =  + threadId);
   Cursor c =
getContentResolver().query(Uri.parse(content://sms/outbox/ +
threadId), null, null,
   null, null);
   c.moveToNext();
   int p = cur.getInt(cur.getColumnIndex(person));
   Log.d(SMS, SMS SEND person=  + p);
   //getContentResolver().delete(Uri.parse(content://sms/
conversations/ + threadId), null, null);

}
else{
  Log.d(SMS, SMS RECIEVE);
   int threadIdIn =
cur.getInt(cur.getColumnIndex(thread_id));

   getContentResolver().delete(Uri.parse(content://sms/
conversations/ + threadIdIn), null, null);
}

 }


}


However I want to be able to get the recipricant and the message text
from the SMS Content Provider, can anyone tell me how to do this?

And also how to delete one message instead of an entire thread?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using remove me as the subject.


[android-developers] Subscribe to onDialogClosed

2010-03-24 Thread draf...@gmail.com
Can anyone give me an example or explain to me how i subscribe to the
onDialogClosed method of an EditTextPreference?

http://developer.android.com/intl/fr/reference/android/preference/EditTextPreference.html#onDialogClosed%28boolean%29

I want to know when a dialog have had its OK or Cancel button clicked
and retrive the information from the EditText.

Is there any examples/tutorials of this available or can anyone point
me in the right direction?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words REMOVE ME as the subject.


[android-developers] How to add my own Audio codec to AudioRecord?

2010-03-10 Thread draf...@gmail.com


I currently have a Loop back program for testing Audio on Android
devices.

It uses AudioRecord and AudioTrack to record PCM audio from the Mic
and play PCM audio out the earpiece.

Here is the code:

public class Record extends Thread
  {

  static final int bufferSize = 20;
  final short[] buffer = new short[bufferSize];
  short[] readBuffer = new short[bufferSize];

  public void run() {
isRecording = true;
android.os.Process.setThreadPriority
(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);

int buffersize = AudioRecord.getMinBufferSize(11025,
AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT);

   arec = new
AudioRecord(MediaRecorder.AudioSource.MIC,
   11025,
 
AudioFormat.CHANNEL_CONFIGURATION_MONO,
 
AudioFormat.ENCODING_PCM_16BIT,
   buffersize);

   atrack = new
AudioTrack(AudioManager.STREAM_VOICE_CALL,
   11025,
 
AudioFormat.CHANNEL_CONFIGURATION_MONO,
 
AudioFormat.ENCODING_PCM_16BIT,
   buffersize,
   AudioTrack.MODE_STREAM);


   atrack.setPlaybackRate(11025);

   byte[] buffer = new byte[buffersize];
   arec.startRecording();
   atrack.play();

   while(isRecording) {

   arec.read(buffer, 0, buffersize);
   atrack.write(buffer, 0,
buffer.length);
   }
  }
  }

So as you can see in the creation of the AudioTrack and AudioRecord
the Encoding is supplied via the AudioFormat but this only allows 16
bit or 8 bit PCM.

I have my own G711 Codec implementation now and I want to be able to
encode the audio from the Mic and decode it going into the EarPiece,
So I have encode(short lin[], int offset, byte enc[], int frames) and
decode(byte enc[], short lin[], int frames) methods but I'm unsure as
to how to use them to encode and the decode the audio from the
AudioRecord and AudioTrack.

Can anyone help me or point me in the right direction?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Supress the native In Call Screen and replace with 3rd party?

2010-03-05 Thread draf...@gmail.com
Currently creating a VOIP application for Android and I was wondering
is there any possible way to supress the In Call Dialog when sending a
call over GSM and use our own 3rd party In Call Dialog or screen
instead?

At the minute when we switch from our VOIP call and send it over GSM
via the ACTION_CALL intent it does everything we want except it brings
up the native In Call screen whereas we want our own In Call screen to
display here.

So I was wondering what kind of options we would have on this?

What would you reccomend we look into doing?

Thanks in advance

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Screen gets locked with 'call end' button, how to unlock?

2010-03-05 Thread draf...@gmail.com
End call key locks the screen on my HTC Hero, to unlock it I press the
menu key

On Mar 5, 9:50 am, Sachin sachinpandh...@gmail.com wrote:
 Hello,
 We have ported Android Eclair on our target.

 After booting the Android and unlocking the screen first time, if we
 press the 'call end' button then the home screen gets locked.
 And we are not able to unlock it.

 Has anyone observed this behavior on their platform?
 How to unlock the screen?
 Is this a special feature?

 thanks,
 Sachin

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Is it possible to have 3G and Wifi connections at the same time?

2010-03-05 Thread draf...@gmail.com

Hi all,

I was wondering does anyone know if its possible to open a wifi and a
3g connection at the same time on Android?

Is there any way to control access to both Wifi and 3g/GPRS data
connections and use them at the same time?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] intents getting incrementing each time received?

2010-03-01 Thread draf...@gmail.com
Hi all,

I have started using custom intents in my application and I have come
across a bit of a problem.

When I send a custom intent I register a Broadcast Receiver and I
catch the intent no problem.

However problems seem to appear when I send the intent again, the
Broadcast Reciever seems to register two events of the intent and so
on so if the intent is sent a third time I recieve it 3 times.

This is causing major problems in my application and was wondering is
it normal and there is some way I have to deal with it?

Here is my code:

To Send the Intent:

Intent i = new Intent();
i.setAction(SIP_INCOMING_CALL_CANCEL_INTENT);
sendBroadcast(i);

To receive the Intent:

sipIncomingListener = new BroadcastReceiver(){

@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();

if(CallDialogActivity.SIP_INCOMING_CALL_ANSWER_INTENT.equals(action)){

Log.d(SIPENGINE, CALL CONNECTED SENT FROM INITINCOMINGLISTENER());

  }
};
IntentFilter filter = new
IntentFilter(CallDialogActivity.SIP_INCOMING_CALL_CANCEL_INTENT);
registerReceiver(sipIncomingListener, filter);

Is there anyway to make sure the Intent is only fired once??

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Ringtone.stop() wont work?

2010-02-26 Thread draf...@gmail.com
I currently start a Ringtone on Android and it plays fine.

However when I try to stop the ringtone it doesn't stop or atleast
doesn't stop straight away, it will keep in playing until it just
plays out.

Here is how I set up the Ringtone:

int rm = audio_service.getRingerMode();
int vs =
audio_service.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);

android.os.Vibrator v = (Vibrator)
getSystemService(Context.VIBRATOR_SERVICE);

if ((rm == AudioManager.RINGER_MODE_VIBRATE ||
(rm == AudioManager.RINGER_MODE_NORMAL  vs ==
AudioManager.VIBRATE_SETTING_ON)))
v.vibrate(vibratePattern,1);

if (audio_service.getStreamVolume(AudioManager.STREAM_RING)  0)
{

oRingtone = RingtoneManager.getRingtone(this,
Settings.System.DEFAULT_RINGTONE_URI);
oRingtone.setStreamType(AudioManager.STREAM_RING);
oRingtone.play();

}

And here is how I try to stop it

if (CallDialogActivity.oRingtone != null) {
  Log.d(RINGTONE, Into Ringtone if);
  Ringtone ringtone = CallDialogActivity.oRingtone;
  oRingtone = null;
  ringtone.stop();
}

Has anyone come across similiar problems or see any mistakes in my
code?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] About box in application manager?

2010-02-08 Thread draf...@gmail.com

I was wondering does anyone know how to give an Android application an
about box in the application manager?

So when a user goes to Settings  Applications  Manage Applications
and clicks on an app there is an About box there that the user can
click and info about the app pops up.

You can see what I mean better over at the Question I have asked on
stackoverflow:

http://stackoverflow.com/questions/2220725/android-about-box-in-application-manager

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Activity seems to get attached to Dialer context?

2010-02-05 Thread draf...@gmail.com
Hi all,

I currently have an application that listens out for the out going
call broadcast, when I recieve the broadcast I pop up an activity on
the screen with some user information.

The user can then press end to remove this screen.

It all works fine however I have a problem when I hold down the home
key and get the recently used apps icons.

The dialer icon appears there and when i click on it my activity comes
back to the front of the device and is displayed on screen.

I dont want this to happen and I was working could my activity
somehwere be getting attached to the dialer context?

My intent for starting my activity is this:

 final Intent myIntent = new Intent(context,
CallDialogActivity.class);

Could the context being passed in somehow be the Dialer? And if so how
to I stop that happening?

Is there a better way to set up the intent so it doesn't use the
context?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Is passing AMR_NB into AudioTrack and AudioRecord valid?

2010-02-03 Thread draf...@gmail.com
I currently use AudioTrack and AudioRecord to create a looping sound
program and I was using raw PCM audio but I want to use AMR_NB audio
so I set up the code as follows

arec = new AudioRecord(MediaRecorder.AudioSource.MIC,
   11025,

AudioFormat.CHANNEL_CONFIGURATION_MONO,

MediaRecorder.AudioEncoder.AMR_NB,
   buffersize);
atrack = new AudioTrack(AudioManager.STREAM_VOICE_CALL,
   11025,

AudioFormat.CHANNEL_CONFIGURATION_MONO,

MediaRecorder.AudioEncoder.AMR_NB,
   buffersize,

AudioTrack.MODE_STREAM);

The above code works fine but is passing
MediaRecorder.AudioEncoder.AMR_NB in as the Audio Format valid or is
it working but actually not being encoded as AMR_NB?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Android - minimal UI, services or broadcast recievers?

2010-01-28 Thread draf...@gmail.com
I have an application that will have no User Interface (not exactly
none altogether but VERY minimal).

I want it to scan for Wifi access points at regular intervals, check
the connected state of Wifi and check the connected level of the
currently connected access point.

It also listens for the OUT_GOING_CALL broadcast and traps the call if
connected to wifi and then pops up a dialog that tells the user the
call has been blocked and offers the user cheaper options than Gsm if
there are any.

I currently use the Broadcasts to get the Scan Results and to get
changes in the connected Level of the wifi connection also.

However I had thought that moving these to a service of my own would
be a good idea, however would I be better leaving them as Broadcast
Recievers in Non Activtiy and Non Service classes and just make the
main Engine of the application a service that turns on and off these
broadcasts from there Classes (Objects) ?

So I was wondering would having several services, one that does the
wifi stuff, one that does the call monitoring, and one that drives the
whole thing?

Or would I be better off using BroadcastRecievers to listen out for
changes instead and implement a timertask to scan for access points
and only have one service being the engine that drives it all?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Loop audio from mic to earpiece?

2010-01-26 Thread draf...@gmail.com
Just another update, it now appears to be working properly in 1.6 +
using thr setSpeakerPhoneOn() method,

I set it to false in the onCreate method, use the voice call stream,
set the volume control to in call and it appears to be working so far

On Jan 25, 12:01 pm, Donal Rafferty draf...@gmail.com wrote:
 Just to update you a bit

 this code works in 1.5 :

         audio_service.setSpeakerphoneOn(false);
         audio_service.setMode(AudioManager.MODE_IN_CALL);
         audio_service.setRouting(AudioManager.MODE_NORMAL,
                         AudioManager.ROUTE_EARPIECE,
 AudioManager.ROUTE_ALL);

 However I've yet to find a solution for 1.6 +

 Any help would be greatly appreciated

 Thanks

 On Mon, Jan 25, 2010 at 9:19 AM, Donal Rafferty draf...@gmail.com wrote:
  Hi Ani,

  I am working on 1.5 (CupCake) and have tried to use the setRouting method,
  however the audio still appears to be coming out of the speaker.

  I also have an eclair device and the audio is coming out of the speaker on
  that device too.

  I have tried using the Audiomanager and the STREAM_VOICE_CALL also but with
  no luck at all.

  My code is posted above in case I may be using the methods the wrong way?

  On Mon, Jan 25, 2010 at 3:09 AM, ani anish198519851...@gmail.com wrote:

  Not 100% sure about the earpiece, but you specify a stream when you
  create the AudioTrack and I think a stream encpsulates audio routing
  and volume amongst possibly other things.

  If you set the stream to STREAM_VOICE_CALL it might come through the
  earpiece as this is where a call would be routed, although I guess
  that depends on headsets and stuff.
  Can anyone clarify if I am right?

  As for earpiece routing we can route audio to earpiece using
  setrouting call in the case of cupcake.In case of ECLAIR you can use
  various custom api's provided by android to route it to earpiece
  (google it).You need to set the route explicitly to get the audio out
  of earpiece or any other place.STREAM_VOICE_CALL will work i think but
  not 100% sure.Please check in case you are not getting let me know.

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Loop audio from mic to earpiece?

2010-01-22 Thread draf...@gmail.com
Hi Micheal,

do you fancy helping me try to solve the ear piece problem to make it
two pints? :-)

It initially sounds like it gets routed to the ear piece on the HTC
Hero but thats because of the way the earpiece and speaker are set up
on the hero, on a G1 it is clearly coming through the speaker.

here is the full code I have:

boolean isRecording; //currently not used
AudioManager am;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
Record record = new Record();
record.run();

}

  public class Record extends Thread
  {

  static final int bufferSize = 20;
  final short[] buffer = new short[bufferSize];
  short[] readBuffer = new short[bufferSize];

  public void run() {
  isRecording = true;
  android.os.Process.setThreadPriority
  (android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);

  int buffersize = AudioRecord.getMinBufferSize(11025,
  AudioFormat.CHANNEL_CONFIGURATION_MONO,
  AudioFormat.ENCODING_PCM_16BIT);

 AudioRecord arec = new AudioRecord
(MediaRecorder.AudioSource.MIC,
 11025,

AudioFormat.CHANNEL_CONFIGURATION_MONO,

AudioFormat.ENCODING_PCM_16BIT,
 buffersize);

 AudioTrack atrack = new AudioTrack
(AudioManager.STREAM_VOICE_CALL,
 11025,

AudioFormat.CHANNEL_CONFIGURATION_MONO,

AudioFormat.ENCODING_PCM_16BIT,
 buffersize,
 
AudioTrack.MODE_STREAM);

 am.setRouting(AudioManager.MODE_NORMAL,
AudioManager.ROUTE_EARPIECE,
 
AudioManager.ROUTE_ALL);

 Log.d(SPEAKERPHONE, Is speakerphone
on? :  + am.isSpeakerphoneOn());

 atrack.setPlaybackRate(11025);

 byte[] buffer = new byte[buffersize];
 arec.startRecording();
 atrack.play();

 while(isRecording) {
 arec.read(buffer, 0, 
buffersize);
 atrack.write(buffer, 0,
buffer.length);
 }

 arec.stop();
 atrack.stop();
 isRecording = false;
  }
  }
}

The log message shows that isSpeakerPhoneOn returns false yet the
audio still comes through the speaker,
The setRouting method is deprecated and doesnt work either and no
matter what stream I choose in the AudioTrack
constructor the audio gets played out over the Speaker.

Cant find much on it with a search either, just people having the same
problems as me.

Would you or anyone have any insight on how to get it to play through
the ear piece?

Thanks again in advance,
Donal


On Jan 21, 5:29 pm, Michael nicholls...@googlemail.com wrote:
 No worries.

 Had a week off in summer and spent some of it watching the tennis in
 the sweltering heat and learning how the AudioRecord and AudioTrack
 stuff works.
 Just polishing some of it up to release my first app, but glad it
 could be of use to someone else as well.

 I look forward to that pint ;-)

 Mike

 On Jan 21, 5:23 pm, Donal Rafferty draf...@gmail.com wrote:

  Thanks Mike,

  Your a legend, have that working now,

  I owe you a pint!

  Many thanks,
  Regards,
  Donal

  On Thu, Jan 21, 2010 at 5:02 PM, Michael nicholls...@googlemail.com wrote:
   Hi Donal,

   I have pulled together some of my code to form an example. I have no
   idea if this code would compile, but it should be pretty close and
   should serve as an example to get you going.

                  android.os.Process.setThreadPriority
   (android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);

                  int buffersize = AudioRecord.getMinBufferSize(11025,
   AudioFormat.CHANNEL_CONFIGURATION_MONO,
   AudioFormat.ENCODING_PCM_16BIT);

                  AudioRecord arec = new
   AudioRecord(MediaRecorder.AudioSource.MIC,
                                  11025

[android-developers] Loop audio from mic to earpiece?

2010-01-21 Thread draf...@gmail.com
Hi all,

I was wondering is it possible with Android to record from the mic and
play the sound back out the earpiece with just a 1 second delay?

I have seen the tutorials and can currently record from the mike and
save a 3gp file to the sd card.

However is it posssible to record and say stream the audio straight to
the ear piece with just a 1 - 2 second delay?

If so how would I go about doing this?

Would I need to record from the mic and save it to a file and then
repaly to the ear piece? and continually do this?

Or would it be possible to record from the mic and stream it directly
to the ear piece with just a slight delay?

Any help, info or directions to tutorials would be greatly
appreciated,

Thanks in advance



-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Loop audio from mic to earpiece?

2010-01-21 Thread draf...@gmail.com
Hi Mike,

Thanks for the prompt reply.

I was looking at the AudioRecord class but had somehow missed the
AudioTrack class,

thanks for pointing it out.

From looking at the classes I think what I have to do is read the
recording data and put it straight into a streamed
AudioTrack, would I be correct in saying that?

And then is it possible to send it to the earpiece?

Thanks again,

Donal

On Jan 21, 11:36 am, Michael nicholls...@googlemail.com wrote:
 AudioRecord and AudioTrack are the classes you need.

 If you use them in streaming mode then you can pipe data out of
 AudioRecord straight into AudioTrack and you should be able to acheive
 the desired effect.

 I have done something similar, but without the delay.

 Mike

 On Jan 21, 11:28 am, draf...@gmail.com draf...@gmail.com wrote:

  Hi all,

  I was wondering is it possible with Android to record from the mic and
  play the sound back out the earpiece with just a 1 second delay?

  I have seen the tutorials and can currently record from the mike and
  save a 3gp file to the sd card.

  However is it posssible to record and say stream the audio straight to
  the ear piece with just a 1 - 2 second delay?

  If so how would I go about doing this?

  Would I need to record from the mic and save it to a file and then
  repaly to the ear piece? and continually do this?

  Or would it be possible to record from the mic and stream it directly
  to the ear piece with just a slight delay?

  Any help, info or directions to tutorials would be greatly
  appreciated,

  Thanks in advance
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Loop audio from mic to earpiece?

2010-01-21 Thread draf...@gmail.com
Hi Micheal,

Thanks again,

I now have it recording in PCM format from the mic and saving it to
the sd card and then
playing it back through the ear piece.

So I just have to look into how to into piping the AudioRecord
straight into the AuditTrack.

So with the AudioRecord instead of creating a file to save to what
should I look into doing?

And with the AudioTrack, instead of looking for a file to read in what
should I look into doing?

Thanks,
Kind Regards,
Donal

On Jan 21, 1:10 pm, Michael nicholls...@googlemail.com wrote:
 Hi Donal,

 Yeah if you kick the record off and the play, then you can sit in a
 loop reading the data out of Record and putting it into play (on a
 thread other than the UI thread of course).

 Not 100% sure about the earpiece, but you specify a stream when you
 create the AudioTrack and I think a stream encpsulates audio routing
 and volume amongst possibly other things.

 If you set the stream to STREAM_VOICE_CALL it might come through the
 earpiece as this is where a call would be routed, although I guess
 that depends on headsets and stuff.

 Can anyone clarify if I am right?

 Mike

 On Jan 21, 11:49 am, draf...@gmail.com draf...@gmail.com wrote:

  Hi Mike,

  Thanks for the prompt reply.

  I was looking at the AudioRecord class but had somehow missed the
  AudioTrack class,

  thanks for pointing it out.

  From looking at the classes I think what I have to do is read the
  recording data and put it straight into a streamed
  AudioTrack, would I be correct in saying that?

  And then is it possible to send it to the earpiece?

  Thanks again,

  Donal

  On Jan 21, 11:36 am, Michael nicholls...@googlemail.com wrote:

   AudioRecord and AudioTrack are the classes you need.

   If you use them in streaming mode then you can pipe data out of
   AudioRecord straight into AudioTrack and you should be able to acheive
   the desired effect.

   I have done something similar, but without the delay.

   Mike

   On Jan 21, 11:28 am, draf...@gmail.com draf...@gmail.com wrote:

Hi all,

I was wondering is it possible with Android to record from the mic and
play the sound back out the earpiece with just a 1 second delay?

I have seen the tutorials and can currently record from the mike and
save a 3gp file to the sd card.

However is it posssible to record and say stream the audio straight to
the ear piece with just a 1 - 2 second delay?

If so how would I go about doing this?

Would I need to record from the mic and save it to a file and then
repaly to the ear piece? and continually do this?

Or would it be possible to record from the mic and stream it directly
to the ear piece with just a slight delay?

Any help, info or directions to tutorials would be greatly
appreciated,

Thanks in advance
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Cant get data from my service

2010-01-19 Thread draf...@gmail.com
I have a service that is running fine and I can see the data
collecting in the logcat,

However after creating an aidl and trying to get the information from
the service to my main activity I have hit a problem.

I just cant seem to get the data to pass across at all, I always get a
null pointer exception.

Here is my service class, I want to get the connectedLevel int to use
in my activity class.

Is it because I'm not binding properly or what am I missing but any
calls to the remote interface to try and get the data ends up with a
null pointer exception.

My activity class code is posted underneath.



Service class

public class WIFIService extends Service{

private static final int WIFI_NOTIFY = 0x2001;
public static final String EXTRA_UPDATE_RATE = update-rate;
public static final String WIFI_SERVICE =
cicero.org.WIFIService.SERVICE;

private WifiManager mainWifi;
private BroadcastReceiver rssiListener = null;

private int updateRate = -1;
private int connectedLevel;


@Override
public void onCreate(){
super.onCreate();
mainWifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
notifier = (NotificationManager) getSystemService
(Context.NOTIFICATION_SERVICE);

}

@Override
public void onStart(Intent intent, int startId){
super.onStart(intent, startId);

updateRate = intent.getIntExtra(EXTRA_UPDATE_RATE, -1);
if(updateRate == -1){

updateRate = 6;

}
 rssiListener = new BroadcastReceiver(){

 @Override
 public void onReceive(Context context, Intent intent) {
 String action = intent.getAction();

 if(WifiManager.RSSI_CHANGED_ACTION.equals(action))
{
WifiInfo data = mainWifi.getConnectionInfo();
Log.d(WIFI SERVICE, RSSI has changed);
if(mainWifi.getConnectionInfo()!=null){
setConnectedLevel(data.getRssi());
Log.d(WIFI SERVICE, new RSSI =  +
data.getSSID()+   + data.getRssi() + dBm);
}
 }
 }
 };

}

@Override
public void onDestroy(){

if(rssiListener != null){
unregisterReceiver(rssiListener);
rssiListener = null;
}

if(wifiChangeListener != null){
unregisterReceiver(wifiChangeListener);
wifiChangeListener = null;
}

if(receiverWifi != null){
unregisterReceiver(receiverWifi);
receiverWifi = null;
}
super.onDestroy();

}
public void setConnectedLevel(int connectedLevel) {
this.connectedLevel = connectedLevel;

}


@Override
public IBinder onBind(Intent intent) {
// we only have one, so no need to check the intent
return mRemoteInterfaceBinder;
}

//  remote interface
private final IRemoteInterface.Stub mRemoteInterfaceBinder = new
IRemoteInterface.Stub() {

@Override
public int getConnectedLevel() throws RemoteException {
Log.v(interface, getConnectedLevel() 
called);
return connectedLevel;
}

};
}




Activity class

public class TestApp extends Activity implements ServiceConnection{

IRemoteInterface mRemoteInterface = null;
int connectedLevel;

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

CallMonitor cm = new CallMonitor(this);
wifi = new WiFi(this);

final Button settings_Button = (Button) findViewById
(R.id.settingsButton);

settings_Button.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v){
final Intent myIntent = new Intent(TestApp.this,
SettingsApp.class);
startActivity(myIntent);

//Toast.makeText(GetCallLog.this, nameE, 
Toast.LENGTH_LONG).show
();
}

});

final Button scan_Button = (Button) findViewById
(R.id.scanButton);

scan_Button.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){

Intent 

[android-developers] Re: READ_SMS permissions not working

2010-01-18 Thread draf...@gmail.com
Hi Moneytoo,

Is there a way to monitor changes in the outbox through an official
API?

I need to be able to listen out for an sms message beinging sent and
be able to deal with that through my own application.

However I have been researching the official API and I cant find
anything that will let me do this?

Is there some way of doing it with the official API that I have
missed?

Thanks in advance

On 15 Jan, 18:58, moneytoo m...@seznam.cz wrote:
 Use content://mms-sms instead if you must but I would recommend you to
 stick with the official API.

 On Jan 15, 3:50 pm, draf...@gmail.com draf...@gmail.com wrote:

  Hi all,

  I keep getting the following error:

  01-15 12:29:28.155: ERROR/DatabaseUtils(115):
  java.lang.SecurityException: Permission Denial: reading
  com.android.providers.telephony.SmsProvider uri content://sms from
  pid=1004, uid=10054 requires android.permission.READ_SMS

  Even though I have the persmission READ_SMS in my manifest, I have
  tried it both outside the application tags and inside, neither way
  seems to work and the same error keeps popping up

  Here is my manifest:

  XML:
  ?xml version=1.0 encoding=utf-8?
  manifest xmlns:android=http://schemas.android.com/apk/res/android;
        package=cicero.org
        android:versionCode=1
        android:versionName=1.0
      application android:icon=@drawable/icon android:label=@string/
  app_name
          activity android:name=.TestApp
                    android:label=@string/app_name
              intent-filter
                  action android:name=android.intent.action.MAIN /
                  category
  android:name=android.intent.category.LAUNCHER /
              /intent-filter
          /activity
          activity android:name=.SettingsApp
                    android:label=@string/app_name
              intent-filter
                  action android:name=android.intent.action.SETTINGS /

                  category
  android:name=android.intent.category.LAUNCHER /
              /intent-filter
          /activity
            provider android:name=.CiceroContentProvider

  android:authorities=cicero.org.CiceroContentProvider
                                android:multiprocess=true /

          receiver android:name=.SMSApp
            intent-filter
                action
  android:name=android.provider.Telephony.SMS_RECEIVED /
             /intent-filter
         /receiver

      /application
      uses-sdk android:minSdkVersion=3 /
      uses-permssion android:name=android.permission.READ_SMS/
      uses-permission android:name=android.permission.READ_CONTACTS/
       uses-permission android:name=android.permission.WRITE_CONTACTS/

       uses-permission
  android:name=android.permission.ACCESS_WIFI_STATE/
       uses-permission
  android:name=android.permission.CHANGE_WIFI_STATE/
       uses-permission android:name=android.permission.WAKE_LOCK/
       uses-permission
  android:name=android.permission.PROCESS_OUTGOING_CALLS/
       uses-permission android:name=android.permission.CALL_PHONE/
       uses-permission android:name=android.permission.RECEIVE_SMS/
       uses-permssion android:name=android.permission.WRITE_SMS/
  /manifest

  Anybody got any ideas if I'm missing something else or why the
  permission is not getting recognized in the manifest?

  Here is my code that I am using:

  //in onCreate()

          String url = content://sms/;
                  Uri uri = Uri.parse(url);
                  getContentResolver().registerContentObserver(uri, true, new
  MyContentObserver(handler));

      //own class
      class MyContentObserver extends ContentObserver {

          public MyContentObserver(Handler handler) {

                  super(handler);

          }

      @Override public boolean deliverSelfNotifications() {
          return false;
          }

      @Override public void onChange(boolean arg0) {
          super.onChange(arg0);

           Log.v(SMS, Notification on SMS observer);

          Message msg = new Message();
          msg.obj = xx;

          handler.sendMessage(msg);

          Uri uriSMSURI = Uri.parse(content://sms/inbox);
          Cursor cur = getContentResolver().query(uriSMSURI, null, null,
                       null, null);
          cur.moveToNext();
          String protocol = cur.getString(cur.getColumnIndex
  (protocol));
          if(protocol == null)
                 Log.d(SMS, SMS SEND);
          else
                  Log.d(SMS, SMS RECIEVE);

      }

  Anybody got any ideas if I'm missing something else or why the
  permission is not getting recognized in the manifest or is it my code
  that is doing something that is currently not allowed?
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http

[android-developers] READ_SMS permissions not working

2010-01-15 Thread draf...@gmail.com
Hi all,

I keep getting the following error:

01-15 12:29:28.155: ERROR/DatabaseUtils(115):
java.lang.SecurityException: Permission Denial: reading
com.android.providers.telephony.SmsProvider uri content://sms from
pid=1004, uid=10054 requires android.permission.READ_SMS


Even though I have the persmission READ_SMS in my manifest, I have
tried it both outside the application tags and inside, neither way
seems to work and the same error keeps popping up

Here is my manifest:

XML:
?xml version=1.0 encoding=utf-8?
manifest xmlns:android=http://schemas.android.com/apk/res/android;
  package=cicero.org
  android:versionCode=1
  android:versionName=1.0
application android:icon=@drawable/icon android:label=@string/
app_name
activity android:name=.TestApp
  android:label=@string/app_name
intent-filter
action android:name=android.intent.action.MAIN /
category
android:name=android.intent.category.LAUNCHER /
/intent-filter
/activity
activity android:name=.SettingsApp
  android:label=@string/app_name
intent-filter
action android:name=android.intent.action.SETTINGS /

category
android:name=android.intent.category.LAUNCHER /
/intent-filter
/activity
  provider android:name=.CiceroContentProvider
 
android:authorities=cicero.org.CiceroContentProvider
  android:multiprocess=true /

receiver android:name=.SMSApp
  intent-filter
  action
android:name=android.provider.Telephony.SMS_RECEIVED /
   /intent-filter
   /receiver

/application
uses-sdk android:minSdkVersion=3 /
uses-permssion android:name=android.permission.READ_SMS/
uses-permission android:name=android.permission.READ_CONTACTS/
 uses-permission android:name=android.permission.WRITE_CONTACTS/

 uses-permission
android:name=android.permission.ACCESS_WIFI_STATE/
 uses-permission
android:name=android.permission.CHANGE_WIFI_STATE/
 uses-permission android:name=android.permission.WAKE_LOCK/
 uses-permission
android:name=android.permission.PROCESS_OUTGOING_CALLS/
 uses-permission android:name=android.permission.CALL_PHONE/
 uses-permission android:name=android.permission.RECEIVE_SMS/
 uses-permssion android:name=android.permission.WRITE_SMS/
/manifest


Anybody got any ideas if I'm missing something else or why the
permission is not getting recognized in the manifest?

Here is my code that I am using:

//in onCreate()

String url = content://sms/;
Uri uri = Uri.parse(url);
getContentResolver().registerContentObserver(uri, true, new
MyContentObserver(handler));


//own class
class MyContentObserver extends ContentObserver {

public MyContentObserver(Handler handler) {

super(handler);

}

@Override public boolean deliverSelfNotifications() {
return false;
}

@Override public void onChange(boolean arg0) {
super.onChange(arg0);

 Log.v(SMS, Notification on SMS observer);

Message msg = new Message();
msg.obj = xx;

handler.sendMessage(msg);

Uri uriSMSURI = Uri.parse(content://sms/inbox);
Cursor cur = getContentResolver().query(uriSMSURI, null, null,
 null, null);
cur.moveToNext();
String protocol = cur.getString(cur.getColumnIndex
(protocol));
if(protocol == null)
   Log.d(SMS, SMS SEND);
else
Log.d(SMS, SMS RECIEVE);


}

Anybody got any ideas if I'm missing something else or why the
permission is not getting recognized in the manifest or is it my code
that is doing something that is currently not allowed?
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Cant find my content provider?

2009-12-21 Thread draf...@gmail.com
Hi,

I have written the following content provider, but when I try to pull
information from it into an array, I get the following error:

12-21 15:14:18.627: ERROR/ActivityThread(1160): Failed to find
provider info for cicero.org.provider.CiceroContentProvider


I presume its something to do with my naming of the CONTENT_URI or
something? I'm not quite sure how it works so could anyone explain a
bit and spot what I have done wrong?

This is what I have in the manifest:

XML:
provider android:name=.CiceroContentProvider
 
android:authorities=cicero.org.provider.CiceroContentProvider /


Java:
public class CiceroContentProvider extends ContentProvider{

 //URI
 public static final Uri CONTENT_URI =
   Uri.parse(content://
cicero.org.provider.CiceroContentProvider);

 //Underlying database

 private SQLiteDatabase settingsDB;

 private static final String TAG = CiceroProvider;
 private static final String DATABASE_NAME = cicero_settings.db;
 private static final int DATABASE_VERSION = 1;
 private static final String SETTINGS_TABLE = settings;


 //Column names
 public final static String _ID = _id;
 public final static String VOIPUSERNAME = voipusername;
 public final static String VOIPAUTHID = voipauthid;
 public final static String PASSWORD = password;
 public final static String SIPPROXYSERVER = sipproxyserver;
 public final static String SIPREGISTRAR = sipregistrar;
 public final static String SIPREALM = siprealm;
 public final static Integer EXPIRESTIME =30;

 //column indexes
 public static final int VOIPUSERNAME_COL = 1;
 public static final int VOIPAUTHID_COL = 2;
 public static final int PASSWORD_COL = 3;
 public static final int SIPPROXYSERVER_COL = 4;
 public static final int SIPREGISTRAR_COL = 5;
 public static final int SIPREALM_COL = 6;
 public static final int EXPIRESTIME_COL = 7;

 //helper class
 private static class settingsDatabaseHelper extends
SQLiteOpenHelper{

  private static final String CREATE_SETTINGS_TABLE
  = CREATE TABLE tbl_settings( +
_ID INTEGER PRIMARY KEY AUTOINCREMENT, +
VOIPUSERNAME TEXT, +
VOIPAUTHID TEXT, +
PASSWORD TEXT, +
SIPPROXYSERVER TEXT, +
SIPREGISTRAR TEXT, +
SIPREALM TEXT, +
EXPIRESTIME INTEGER);;

  public settingsDatabaseHelper(Context context, String name,
CursorFactory factory, int version) {
   super(context, name, factory, version);

  }

  @Override
  public void onCreate(SQLiteDatabase db) {
   db.execSQL(CREATE_SETTINGS_TABLE);

  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int
newVersion) {
   Log.w(TAG, Upgrading database from version  +
oldVersion +  to  +
  newVersion + , which will destroy all old
data);

   db.execSQL(DROP TABLE IF EXISTS  + SETTINGS_TABLE);
   onCreate(db);

  }

 }

 //end helper class


 private static final int SETTINGS = 1;
 private static final int SETTINGS_ID = 2;

 private static final UriMatcher uriMatcher;

 static{
  uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
  uriMatcher.addURI
(cicero.org.provider.CiceroContentProvider, settings, SETTINGS);
  uriMatcher.addURI
(cicero.org.provider.CiceroContentProvider, settings/#,
SETTINGS_ID);
 }


 @Override
 public String getType(Uri uri) {
  switch(uriMatcher.match(uri)){
  case SETTINGS:
   return vnd.android.cursor.dir/
vnd.org.CiceroContentProvider;
  case SETTINGS_ID:
   return vnd.android.cursor.item/
vnd.org.CiceroContentProvider;
  default:
   throw new IllegalArgumentException(Unsupported URI: 
+ uri);
  }

 }



 @Override
 public boolean onCreate() {
  Context context = getContext();

  settingsDatabaseHelper dbHelper;
  dbHelper = new settingsDatabaseHelper(context,
DATABASE_NAME, null, DATABASE_VERSION);

  SQLiteDatabase settingsDB = dbHelper.getWritableDatabase();
  return (settingsDB == null) ? false : true;
 }

 @Override
 public Cursor query(Uri uri, String[] projection, String
selection,
   String[] selectionArgs, String sortOrder) {

  SQLiteQueryBuilder qBuilder = new SQLiteQueryBuilder();

  qBuilder.setTables(SETTINGS_TABLE);

  switch(uriMatcher.match(uri)){

  case SETTINGS_ID:
   qBuilder.appendWhere(_ID + = + uri.getPathSegments
().get(1));
   break;
  default:
   break;

  }

  String orderBy;

  if(TextUtils.isEmpty(sortOrder)){

 

[android-developers] managedQuery - Nullpointerexception

2009-12-17 Thread draf...@gmail.com
Having a problem with the managedQuery below,

I am trying to get the value of the CallLogs.Calls.TYPE or in other
words the type of the call, missed, answered, dialled.

however I keep getting this error 12-17 15:17:50.580: WARN/System.err
(1488): android.database.CursorIndexOutOfBoundsException: Index -1
requested, with a size of 1

Cant quite make out what it means myself, calls.count shows that it
does find the one record for the callRowId, so why is it saying Index
-1 requested?


String [] requestedColumns = {
CallLog.Calls.TYPE

};

try{
Cursor calls = managedQuery(
CallLog.Calls.CONTENT_URI, requestedColumns,
CallLog.Calls._ID + =?, new String[]
{callRowId},null);



int callTypeIndex = calls.getColumnIndex(CallLog.Calls.TYPE);
int callType = calls.getInt(callTypeIndex);

}catch(RuntimeException e){

e.printStackTrace();
}

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Call Log Questions

2009-12-16 Thread draf...@gmail.com
Hi all,

I have been trying to Query, insert and update the Call Log for the
past few days.

Query is fine, have no problem with that.

But I'm wondering does the content provider allow you to add a new
event to the call log or update events already on the call log?

I see there is no CallLog.Calls.CONTENT_DIRECTORY option for adding
new data like there is with the Contacts content provider.

I have also tried updating an event already on the call log but this
has left errors in the program, the calls queried dont display and
when I go to the Call Log screen it crashes.

Here is the code

ContentValues values = new ContentValues();

values.put(CallLog.Calls.CACHED_NAME, TestCase1);

Uri uri = ContentUris.withAppendedId(CallLog.Calls.CONTENT_URI,
1);

int rows = getContentResolver().update(uri, values, null, null);

Log.d(DEBUG, Rows Updated:  + rows);

I get an uncaught handler and null pointer exception error

Is my problem that its not possible to add or update to the call log
content provider or should it be possbile?

Thanks

Donal

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Adding, Editing, Deleting entries in Androids call log

2009-12-15 Thread draf...@gmail.com
Hi,

I have been looking at Androids call log content provider and have
managed to pull the data from it and display it in my own app.

However I want to be able to write to the call log, is there anyway of
doing this?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en