unit Gradation; unit MUnit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Controls.Presentation, FMX.StdCtrls, Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.JavaTypes, FMX.Helpers.Android, AndroidApi.Helpers, Androidapi.JNIBridge, Androidapi.JNI.Net; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.fmx} procedure TForm1.Button1Click(Sender: TObject); var PM: JPackageManager; mainIntent: JIntent; LaunchIntent: JIntent; pkgAppsList: JList; ri: JResolveInfo; iter: JIterator; midlist : TStringList; begin PM := SharedActivityContext.getPackageManager; mainIntent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_MAIN, nil); mainIntent.addCategory(TJIntent.JavaClass.CATEGORY_LAUNCHER); pkgAppsList := PM.queryIntentActivities(mainIntent, 0); midlist := TStringList.Create; iter := pkgAppsList.iterator; while iter.hasNext do begin ri := TJResolveInfo.Wrap((iter.next as ILocalObject).GetObjectID); mIdList.Add(JStringToString(ri.activityInfo.applicationInfo.packageName)); end; LaunchIntent := PM.getLaunchIntentForPackage(StringToJString(mIdList[2])); // 특정 앱 실행 방법. // LaunchIntent := PM.getLaunchIntentForPackage(StringToJString( 'com.samsung.android.messaging') ); // SharedActivityContext.startActivity( LaunchIntent ) showmessage( mIdList.Text ); end; procedure TForm1.Button2Click(Sender: TObject); var PM: JPackageManager; Intent: JIntent; //Declares the intent object begin PM := SharedActivityContext.getPackageManager; Intent := TJIntent.Create; Intent.setData( TJnet_Uri.JavaClass.parse(StringToJString('smsto:01012345678'))); // sms // Intent.setData(TJnet_Uri.JavaClass.parse(StringToJString('tel:' + ANumber))); // call Intent.putExtra(TJIntent.JavaClass.EXTRA_TEXT, StringtoJString( 'Hellow' )); Intent.setAction(TJIntent.JavaClass.ACTION_VIEW); //Defines the Action. if SharedActivityContext.getPackageManager.queryIntentActivities(Intent, TJPackageManager.JavaClass.MATCH_DEFAULT_ONLY).size > 0 then //Checks if there is at least one application capable of receiving the intent. SharedActivityContext.startActivity(Intent) //Calls startActivity() to send the intent to the system. else ShowMessage('Receiver not found'); end; end. |
댓글 없음:
댓글 쓰기