×
Namespaces

Variants
Actions
Revision as of 10:02, 30 July 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Realizando Chamadas Telefônicas a partir de platformRequest()

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

Testado com
Aparelho(s): Nokia N95 8GB

Compatibilidade
Artigo
Palavras-chave: javax.microedition.midlet.MIDlet, javax.microedition.midlet.MIDlet.platformRequest()
Tradução:
Por thiagobrunoms
Última alteração feita por hamishwillee em 30 Jul 2013

Contents

Introdução

Este exemplo mostra como realizar chamadas telefônicas utilizando o método platformRequest(). A MIDlet constrói um menu no qual o usuário pode realizar a chamada a partir do número especificado. Após a invocação do platformRequest, o usuário é perguntado se ele deseja realizar uma ligação de voz, de vídeo ou de Internet.

Código-fonte

import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
public class ExampleMIDlet extends MIDlet implements CommandListener {
private Command callCommand;
private Command exitCommand;
private Form mainForm;
// The phone number to call
private final String PHONE_NUMBER = "0700123123";
 
/**
* Constructor. constrói o objeto e cria os displayables
*/

public ExampleMIDlet() {
mainForm = new Form("ExampleMIDlet");
 
callCommand = new Command("Chamar", Command.SCREEN, 0);
mainForm.addCommand(callCommand);
 
exitCommand = new Command("Sair", Command.EXIT, 0);
mainForm.addCommand(exitCommand);
 
mainForm.setCommandListener(this);
}
 
/**
* Liga para o número especificado a partir de platformRequest()
*/

private void call(String number) {
try {
platformRequest("tel:" + number);
} catch (ConnectionNotFoundException ex) {
// TODO: Exception handling
}
}
 
/**
* Invocado quando a MIDlet é inicializada
*/

public void startApp() {
Display.getDisplay(this).setCurrent(mainForm);
}
 
// Outros métodos herdados da MIDlet foram omitidos
// ...
 
/**
* From CommandListener.
* Invocado pelo gerenciador de aplicativos para informar que um comando foi disparado
* particular displayable.
* @param command o objeto Command que recebeu o evento
* @param displayable o objeto displayable no qual o comando está associado
*/

public void commandAction(Command command, Displayable displayable) {
if (command == callCommand) {
call(PHONE_NUMBER);
} else if (command == exitCommand) {
// Finaliza a MIDlet
destroyApp(true);
notifyDestroyed();
}
}

Pós-condições

O usuário pode selecionar Chamar para realizar a chamada telefônica para o número especificado. O usuário também pode selecionar qual tipo de chamada ele deseja: voz, vídeo ou Internet.

See also

Version Hint

Windows Phone: [[Category:Windows Phone]]
[[Category:Windows Phone 7.5]]
[[Category:Windows Phone 8]]

Nokia Asha: [[Category:Nokia Asha]]
[[Category:Nokia Asha Platform 1.0]]

Series 40: [[Category:Series 40]]
[[Category:Series 40 1st Edition]] [[Category:Series 40 2nd Edition]]
[[Category:Series 40 3rd Edition (initial release)]] [[Category:Series 40 3rd Edition FP1]] [[Category:Series 40 3rd Edition FP2]]
[[Category:Series 40 5th Edition (initial release)]] [[Category:Series 40 5th Edition FP1]]
[[Category:Series 40 6th Edition (initial release)]] [[Category:Series 40 6th Edition FP1]] [[Category:Series 40 Developer Platform 1.0]] [[Category:Series 40 Developer Platform 1.1]] [[Category:Series 40 Developer Platform 2.0]]

Symbian: [[Category:Symbian]]
[[Category:S60 1st Edition]] [[Category:S60 2nd Edition (initial release)]] [[Category:S60 2nd Edition FP1]] [[Category:S60 2nd Edition FP2]] [[Category:S60 2nd Edition FP3]]
[[Category:S60 3rd Edition (initial release)]] [[Category:S60 3rd Edition FP1]] [[Category:S60 3rd Edition FP2]]
[[Category:S60 5th Edition]]
[[Category:Symbian^3]] [[Category:Symbian Anna]] [[Category:Nokia Belle]]

This page was last modified on 30 July 2013, at 10:02.
85 page views in the last 30 days.
×