How can i get android sms PDUS data in Delphi Android BroadcastReceiver

I'm trying to get delphi android sms input with sms broadcastreceiver. But 'type cast' returns nil object.

First i'm getting bundle in intent like eclipse android, but i cannot continue coding for reading sms input because *JObject to TJavaArray<JObject>* casting returns to me nil object.

My codes here

{code}
using Androidapi.JNI.JavaTypes, Androidapi.JNI.Telephony, Androidapi.JNIBridge;

procedure TMainScreen.BroadcastReceiver2Receive(Context: JContext; Intent: JIntent); 
var 
  obj: JObject; 
  I: Integer;
  msg : JSmsMessage;
  pdus : TJavaArray<JObject>;
  newPhoneNumber, text : string; 
begin
  if SameText(JStringToString(Intent.getAction), 'android.provider.Telephony.SMS_RECEIVED') then
  begin
    Memo1.Lines.Add('SMS Received');


    if not BroadcastReceiver2.HasPermission('android.permission.RECEIVE_SMS') then
    begin
      ShowMessage('You don''t have permission for Receive SMS!');
      Exit;
    end
    else
    begin
      try
        obj := Intent.getExtras().get(StringToJString('pdus'));
        pdus := TJavaArray<JObject>.Create;
        pdus := TJavaArray<JObject>(obj);

        for I := pdus.Length - 1 downto 0 do
        begin
          msg := TJSmsMessage.JavaClass.createFromPdu(TJavaArray<Byte>(pdus[i]));
          newPhoneNumber := JStringToString(msg.getOriginatingAddress);
          text := JStringToString(msg.getDisplayMessageBody);
        end;

        Memo1.Lines.Add(newPhoneNumber + #13#10 + text);
      except
        on E: Exception do
          Memo1.Lines.Add(E.Message);
      end;
    end;
  end;
end;
{code}

How can i read sms input in broadcastreceiver with delphi ?
0
Utf
4/4/2015 2:29:07 PM
embarcadero.delphi.firemonkey 4901 articles. 4 followers. Follow

2 Replies
2480 Views

Similar Articles

[PageSpeed] 27

http://www.fmxexpress.com/free-broadcast-receiver-component-for-delphi-xe7-firemonkey-on-android/
0
Eli
4/7/2015 1:15:34 AM
Hello,

another tip: such system level questions only being for a single OS are
better suited for being asked in the OS specific groups. In this case
embarcadero.,public.delphi.platformspecific.android

This group here is more about FMX GUI questions.

Greetings

Markus
0
Markus
4/20/2015 7:20:47 PM
Reply:

Similar Artilces:

[Android] TImage3D can not display on Android (Delphi XE7)
TImage3D can not display any image on Android,Only display black color in TImage3D. But it can be displayed in the windows platform. Android Phone: Nexus5 Version: Delphi XE7 Test step: Create a new Blank project of Multi-Device Application and add a 3D Form , Add a TImage3D control and set property "Bitmap" with any Image/Picuture (etc: PNG or JPG picture),run on Android phone, then you can found the android form display the Image3D with full black color ,not display any picture. But it can be displayed in the windows platform. There is a bug in XE7 so that no material or im...

How can I convert PDUS data from Java to Delphi to broadcast incoming SMS? [Edit]
Hello, I need to develop an apps that broadcast incoming SMS. But I don't know how write delphi code to convert pdus java object to use in firemonkey android app. Can someone help me? I use delphi xe6 Follow java code to broadcast incoming sms: public void onReceive(Context context, Intent intent) { //---get the SMS message passed in--- Bundle bundle = intent.getExtras(); SmsMessage[] msgs = null; String str = ""; if (bundle != null) { //---retrieve the SMS message received--- ...

How can I convert PDUS data from Java to Delphi to broadcast incoming SMS? [Edit]
Hello, I need to develop an apps that broadcast incoming SMS. But I don't know how write delphi code to convert pdus java object to use in firemonkey android app. Can someone help me? I use delphi xe6 From android developer site: Edited by: Angelo Lopez on Jan 8, 2015 5:46 AM Edited by: Angelo Lopez on Jan 8, 2015 9:52 AM Edited by: Angelo Lopez on Jan 12, 2015 12:12 PM ...

How can I convert PDUS data from Java to Delphi to broadcast incoming SMS? [Edit] #2
Hello, I need to develop an apps that broadcast incoming SMS. But I don't know how write delphi code to convert pdus java object to use in firemonkey android app. Can someone help me? I use delphi xe6 Follow java code to broadcast incoming sms: public void onReceive(Context context, Intent intent) { //---get the SMS message passed in--- Bundle bundle = intent.getExtras(); SmsMessage[] msgs = null; String str = ""; if (bundle != null) { //---retrieve the SMS message received--- ...

Delphi - android
I am integrating a third party Bluetooth printer into my Delphi XE7 Android app. For this they have provided the Jar file, license file and the manual. I used the JAVA2OP tool to generated the Delphi native bridge file from the java library. In the manual they mentioned that the License file is required to be added in the raw folder of your application project. How we do this in the Delphi? what I done is in the Project->Deployment added this file and given the remote path as 'res\raw'. is it correct? Sec ondly they are mentioning create an object of the class 'setup', I di...

Does Delphi XE5 on Android work with the Android emulator? [Edit]
I find that even a hello-world app exactly like the one that David I outlines (add a button, one line of code, set button text) will not run on the Android Emulator configured out of the box. First, after installing the Rad Studio XE5 trial, I followed David I's steps exactly, and the emulator would not even start. Then I clicked Android SDK manager, updated it, and clicked run-without-debugging. It asked me if I wanted to start the emulator this time so I did. Now the Firemonkey app will not start up the emulator, and while it does appear to start debugging, the emulator scree...

Delphi for Android
If this is not the right forum, please direct me to the right one. I want to write a simple application for android. Is it possible? I have bought Delphi XE2 and downloaded Andoid sdk. Is there any site to guide me step by step for this job? Can I do the same task with Free Pascal, or even better with Lazarus? Regarding FPC or Lazarus, I need it for highschool teaching purposes. Thanks a lot in advance, Dimitris Dimitris Koutsourelis wrote: > If this is not the right forum, please direct me to the right one. > I want to write a simple application for android. Is it possible?...

Delphi and Android
I just bought a Huawei Ascend P6 that supports NEOS, so I immediately set to create a simple app for example, a button and a label where clicking on the first time out on the second, no big deal, BUT, with my displeasure, after the compilaizione I transferred the APK file is in the cell, I installed it, but launching the app exits ONLY a white screen and does nothing, however, and the app is not locked! Someone gave to this same problem? I also tried with the examples in the Sample folder, but nothing. I created a virtual phone with AVD (Nexus 4) and I created a simple app and every...

Get the fat out from XE5 Android apps
In the modern mobile OSes (like iOS and Android) the applications are run into a sandbox for more control, security and performance reasons and there are no (easy) ways to separate/use a "runtime" library (in Delphi's case RTL + FireMonkey) to be shared by multiple apps. This problem is common to all mobile x-plat runtimes/wrappers like Adobe AIR (http://www.adobe.com/products/air.html) or Mono (http://www.mono-project.com). In Delphi's case the problem with the increasingly fat apps (statically linking RTL + FireMonkey to the application binary) comes from the non-optimi...

send sms android app delphi xe7
i have written following code for send sms on delphi xe7 but i have following error { java.lang.securityexception: sending sms message : uid10176 does not have android.permission.send_sms } { unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, FMX.Helpers.Android, Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.Net, Androidapi.JNI.JavaTypes, Androidapi.JNI.Telephony, Androidapi.Helpers; type TForm1 = c...

Does an android app created with Delphi XE5, XE6 run on Android 5 without modifications?
Is a FireMonkey NDK application forward compatible as much as a JDK one? Markus wrote: > Android changed the JVM from Dalvik to another one (just forgot the > name) The new runtime is called ART. > and that caused issues with Delphi based programs which had any > images in them as TImage.LoadFromStream didn't work properly > anymore and a few small other issues. But that was not a problem with the NDK itself. Just that there was a new runtime underneath the NDK, and FMX was making some assumptions that work under Dalvik but not under ART. -- Remy ...

is possible to build an Android .SO with Delphi Firemonkey XE6 ? Thanks.
is possible to build an Android .SO with Delphi Firemonkey XE6 ? Thanks. > {quote:title=Aldo Lacavalla wrote:}{quote} > is possible to build an Android .SO with Delphi Firemonkey XE6 ? Thanks. Have a look in your Android output directory -- Linden "Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source" > {quote:title=Linden ROTH wrote:}{quote} > > {quote:title=Aldo Lacavalla wrote:}{quote} > > is possible to build an Android .SO with Delphi Firemonkey XE6 ? Thanks. > > > Have a look in ...

Android C demo program to Firemonkey Delphi (Will Pay)
I have a C demo program for the Android platform that I need to convert to Firemonkey and Delphi XE5. This demo logic is written in pure C, and reads one of 5 canned barcodes. Page39a contains those barcodes. The goal is to scan those codes and react accordingly. This conversion will serve as a learning process for me. I am willing to pay for this conversion if need be. Thanking you all in advance and I look forward to any recommendations. Andy http://www.odesk.com/ has developers for hire. Thanks Eli. I will check it out. Andy On Thu, 29 May 2014 06:18:43 -0700, Eli...

Delphi XE5 can not build Android application. Speed is very very low???
My computer: SONYVAIO, RAM 4 GB , CPU Intel core 2 duo 2 GHz, OS Windows Vista home (sp2) My test application have only 1 button, 1 edit, 1 chat with any value (no connetion database). I build/run it into simulator very low. It spend about 9 minutes. How can i get higher speed? Tuan Nguyen wrote: > My computer: SONYVAIO, RAM 4 GB , CPU Intel core 2 duo 2 GHz, OS Windows Vista home (sp2) > > My test application have only 1 button, 1 edit, 1 chat with any value (no connetion database). I build/run it into simulator very low. It spend about 9 minutes. > > How can i g...

Web resources about - How can i get android sms PDUS data in Delphi Android BroadcastReceiver - embarcadero.delphi.firemonkey

Hottest 'android-widget' Answers - Stack Overflow
Q&A for professional and enthusiast programmers

Android & iPhone developer SDK - The Parking Network
public class LocationReceiver extends BroadcastReceiver { public static final String ANAGOG_DRIVING = "anagog.pd.service.intent.DRIVING_EVENT"; ...

android.app - Android Developers
Contains high-level classes encapsulating the overall Android application model. An Android application is defined using one or more of Android's ...

Application security - Android Open Source Project
Android provides an open source platform and application environment for mobile devices. The core operating system is based on the Linux kernel. ...

[Bug Watch] Stopping Apps On Android 4.4.2 Can Silently Kill Related Background Services, A Fix Is On ...
One of the fundamental differences between Android and every other mobile operating system is the practically unrestricted capability to run ...

Cross Reference: /frameworks/base/packages/SystemUI/src/com/android/systemui/qs/UsageTracker.java
1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may ...

Porn clicker app slipped into Google Play imitating popular Dubsmash app
Everyone from celebrities like Lena Dunham to Hugh Jackman are using the (currently) seventh most popular app available on Google Play: Dubsmash. ...

Basic4android (Basic for Android) - Android programming with Gui designer
Basic4android (Basic for Android) is a simple and powerful development environment for developers of Android applications.

SDK for Android M (preview) is available now
Android-er For Android development, from beginner to beginner. Thursday, May 28, 2015 SDK for Android M (preview) is available now Android SDK ...

java - Brave New Geek
I spent the better part of two days working on Bluetooth connectivity for an Android app I’m developing. Going into it, I had virtually no experience ...

Resources last updated: 1/18/2016 8:20:33 PM