3

BlackBerry에서 프로그래밍 방식으로 SMS를 보내려고합니다.블랙 베리에서 프로그래밍 방식으로 SMS를 보내는 방법

당신이 어떤 생각을 가지고있는 경우 나 제안하십시오 ..

그리고 어디 선가 읽고, 나는 sendind SMS에 대한 서버 측뿐만 아니라 클라이언트 측 코드가 필요합니다. 그것은 사실입니까? 한 장치에서 다른 장치로 또는 에뮬레이터에서 장치로 메시지를 보내려면 클라이언트 측 코드뿐만 아니라 서버 측도 필요합니까? 당신은 어떤 서버가 필요하지 .. 내가 클라이언트 측 곳이 코드를 찾았지만, 내가 도와 output..Please 받고 있지 않다

.. 사전에

private void sendSMS(String phone, String message) throws RuntimeException, ServicesManagerException, IOException 
    { 
     // TODO Auto-generated method stub 

     System.out.println("in send sms function"); 
     MessageConnection conn = 
      (MessageConnection)Connector.open("sms://+919099087960"); 
     BinaryMessage msgOut = (BinaryMessage) conn.newMessage(MessageConnection.BINARY_MESSAGE); 
     msgOut.setPayloadData("my binary payload".getBytes("UTF-8")); 
     conn.send(msgOut); 

    } 
+0

내 코드에는 RunTime 예외가 발생합니다. 제발 도와주세요 .. 고마워, .. .. –

+0

@ Riddhi - 나는 같은 종류의 문제가 있습니다 ... 완료까지 앱을 실행할 수 있지만 BlackBerry Simulator의 'Messages'폴더에 내 메시지가 표시되지 않습니다! 그걸 도와 줄 수 있니? –

답변

5

을 me..Thanks 가이드하세요 사이드 코드. 다음 코드를 확인하십시오.

static String msg="hai"; 
try { 
    new Thread() { 
     public void run() { 
      if (RadioInfo.getNetworkType() == RadioInfo.NETWORK_CDMA) { 
       DatagramConnection dc = null; 
       try { 
        dc = (DatagramConnection) Connector.open("sms://+919099087960"); 
        byte[] data = msg.getBytes(); 
        Datagram dg = dc.newDatagram(dc.getMaximumLength()); 
        dg.setData(data, 0, data.length); 
        dc.send(dg); 
        UiApplication.getUiApplication().invokeLater(new Runnable() { 
         public void run() { 
          try { 
           System.out.println("Message Sent Successfully : Datagram"); 
           Dialog.alert("Message Sent Successfully"); 
          } catch (Exception e) { 
           System.out.println("Exception : " + e.toString()); 
           e.printStackTrace(); 
          } 
         } 
        }); 
       } catch (Exception e) { 
        System.out.println("Exception : " + e.toString()); 
        e.printStackTrace(); 
       } finally { 
        try { 
         dc.close(); 
         dc = null; 
        } catch (IOException e) { 
         System.out.println("Exception : " + e.toString()); 
         e.printStackTrace(); 
        } 
       } 
      } else { 
       MessageConnection conn = null; 
       try { 
        conn = (MessageConnection) Connector.open("sms://+919099087960"); 
        //generate a new text message 
        TextMessage tmsg = (TextMessage) conn.newMessage(MessageConnection.TEXT_MESSAGE); 
        //set the message text and the address 
        tmsg.setAddress("sms://+919099087960"); 
        tmsg.setPayloadText(msg); 
        //finally send our message 
        conn.send(tmsg); 
        UiApplication.getUiApplication().invokeLater(new Runnable() { 
         public void run() { 
          try { 
           System.out.println("Message Sent Successfully : TextMessage"); 
           Dialog.alert("Message Sent Successfully : TextMessage"); 
          } catch (Exception e) { 
           System.out.println("Exception : " + e.toString()); 
           e.printStackTrace(); 
          } 
         } 
        }); 
       } catch (Exception e) { 
        System.out.println("Exception : " + e.toString()); 
        e.printStackTrace(); 
       } finally { 
        try { 
         conn.close(); 
         conn = null; 
        } catch (IOException e) { 
         System.out.println("Exception : " + e.toString()); 
         e.printStackTrace(); 
        } 
       } 
      } 
     } 
    }.start(); 
} catch (Exception e) { 
    System.out.println("Exception : " + e.toString()); 
    e.printStackTrace(); 
} 
+1

읽을 수없는 코드 –

+0

@ Signare- 나는 같은 종류의 문제가 있습니다 ... 완료까지 응용 프로그램을 실행할 수 있습니다. ("Message Sent Successfully : TextMessage"에 대한 대화 상자가 표시됩니다.)하지만 'Messages'폴더에 내 메시지가 표시되지 않습니다. BlackBerry Simulator! 그걸 도와 줄 수 있니? –

관련 문제