Dial an option (1 or 2 or ) during a call.

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Dial an option (1 or 2 or ) during a call.

Postby android_beggnr » Wed Jan 14, 2009 8:39 pm

Hi, I am trying to emulate the key press after a call is pressed. I mean like calling a helpdesk where we have to dial a number intially and then dial a number to reach a part of the menu.

This is the code I could write so far. Can some body help me?

Code: Select all
[syntax="java"]
package com.mallik.andriod.hello;

import android.app.ListActivity;
import java.util.Hashtable;
import android.content.ContentUris;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Contacts;
import android.provider.Contacts.People;
import android.provider.Contacts.Phones;
import android.view.View;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;


public class HelloAndriod extends ListActivity {
    private ListAdapter mAdapter;
    String[][] data = new String[100][2];
    Hashtable h1 = new Hashtable(500,(float)0.75);
    Hashtable h2 = new Hashtable(500,(float)0.75);
   
     /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
       super.onCreate(icicle);
       String[] s = new String [] {People._ID,People.NAME,People.PRIMARY_PHONE_ID,
                                              People.NUMBER};
       
       int[] names1 = new int[] {R.id.row_entry};
       //int[] names2 = new int[] {R.id.row_entry};
       String[] columns = new String[] {People.NAME,People.NUMBER};

     
         Cursor c = getContentResolver().query(People.CONTENT_URI,s,null,null,null);
       /*
        * startManagingCursor(c);
        * Cursor cur = managedQuery(People.CONTENT_URI, s, null, null, null );
        *
        */
        if (c.moveToFirst()) {
           String name = null;
           int phoneid = 0;
           String phoneno = null;
           do {
              name = c.getString(c.getColumnIndex(People.NAME));
                phoneid = c.getInt(c.getColumnIndex(People.PRIMARY_PHONE_ID));
                phoneno = c.getString(c.getColumnIndex(People.NUMBER));
                h1.put(name,(int)phoneid);
                h2.put(phoneid, phoneno);
           } while (c.moveToNext());
           }
       
        mAdapter = new SimpleCursorAdapter(this,R.layout.main,c,columns,names1);
       
        setListAdapter(mAdapter);
}

   protected void onListItemClick(ListView l, View v, int position, long id) {
      // TODO Auto-generated method stub
      super.onListItemClick(l, v, position, id);
      Intent I = new Intent(Intent.ACTION_CALL);
      long phoneId= 0;
          
      Integer In =  (Integer)h1.get("Rel");   
      String s1 = (String)h2.get(position+1);
      int rpos=In.intValue();
      
      if (s1.startsWith("+91")) phoneId= (int)rpos;
      else phoneId= (int)(position+1);
      
      I.setData(ContentUris.withAppendedId(Phones.CONTENT_URI, phoneId));
      startActivity(I);
}
}[/syntax]
android_beggnr
Freshman
Freshman
 
Posts: 5
Joined: Thu Nov 06, 2008 8:45 pm

Top

Postby MrSnowflake » Wed Jan 14, 2009 9:39 pm

To press buttons you can use <phonenumber>p<button1><button2><button3>...

The p stands for pause if I'm correct. Works for almost every phone.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby android_beggnr » Thu Jan 15, 2009 7:37 pm

Mr. Snowflake, thank you for your answer but how exactly am I supposed to do this programatically. Sorry for being so dumb.

How do I send the key strokes to the phone programatically.
android_beggnr
Freshman
Freshman
 
Posts: 5
Joined: Thu Nov 06, 2008 8:45 pm

Postby android_beggnr » Thu Jan 15, 2009 8:43 pm

I could find the solution but not an complete one for my requirement.

Any way the solution,

http://forums.t-mobile.com/tmbl/board/m ... ad.id=6476.

But I am not sure how to add more pauses by this.
android_beggnr
Freshman
Freshman
 
Posts: 5
Joined: Thu Nov 06, 2008 8:45 pm

Postby android_beggnr » Thu Jan 15, 2009 9:13 pm

android_beggnr
Freshman
Freshman
 
Posts: 5
Joined: Thu Nov 06, 2008 8:45 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot] and 5 guests