OK I found that I needed a permission, this doing a little try {} catch
() {}. See the updated code.
Now the problem is: how can I bypass the default USSD behaviour, in
order to catch it for my purposes instead of popping up the messages
like "Executing USSD code..." (reply)?

Thanks

package com.elegos.windinforma;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.TextView;

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

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

        String encodedHash = Uri.encode("#");

        this.view = (TextView) findViewById(R.id.main);
        this.view.setText("Caricamento dati in corso...");
        call("*123" + encodedHash);
    }

    protected void call(String phoneNumber) {
        this.view.append("\n"+phoneNumber);
        try {
                startActivityForResult(new Intent("android.intent.action.CALL",
Uri.parse("tel:" + phoneNumber)), 1);
        } catch (Exception eExcept) { this.view.append("\n\n
\n"+eExcept.toString()); }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
        this.view.append("\nUSSD: " + requestCode + " " + resultCode + "
" + data);
    }
}

On 18 Lug, 21:52, elegos <[email protected]> wrote:
> Hi there!
> I've just started coding for Android. My network provider has a
> service via USSD to let you know what's your credit, your various
> bonuses and so on, and so I decided to create an activity to get that
> data for the user instead of "calling" it.
>
> So far I've found only a little on this, can't find even any
> documentation on it. This is the code I've got so far:
>
> package com.elegos.windinforma;
>
> import android.app.Activity;
> import android.content.Intent;
> import android.net.Uri;
> import android.os.Bundle;
> import android.widget.TextView;
>
> public class WindInforma extends Activity {
>     private TextView view;
>     /** Called when the activity is first created. */
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
>
>         String encodedHash = Uri.encode("#");
>
>         this.view = (TextView) findViewById(R.id.main);
>         call("*123" + encodedHash); // just an example: credit
>     }
>
>     protected void call(String phoneNumber) {
>         startActivityForResult(new Intent
> ("android.intent.action.CALL",
>                        Uri.parse("tel:" + phoneNumber)), 1);
>     }
>
>     @Override
>     protected void onActivityResult(int requestCode, int resultCode,
> Intent data) {
>         view.setText("USSD: " + requestCode + " " + resultCode + " " +
> data);
>     }
>
> }
>
> It ends unexpectedly. Do you know anything it may help me?
>
> I'm developing in Android 1.5
> Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"android-framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/android-framework?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to