1

I'm using FireMonkey for Android with C++ Builder 10.1. I have to call Java methods from C++ with C++ Builder. But I could not find a way for this. Have you got examples for this job? Or how can I call Java methods from C++ Builder for Android?

I'm trying call to the following Java code:

package com.javacodes;

import java.util.Calendar;

import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.widget.DatePicker;
import android.widget.TimePicker;
import android.widget.Toast;
import android.content.Context;

public class Picker
{
    private static Calendar calendar = Calendar.getInstance();
    private static String date, time;
    private static Context c;

    public Picker()
    {
    }

    public static String datePickerDialog(Context context)
    {
        c = context;
        DatePickerDialog datePickerDialog = new DatePickerDialog(c,
                new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker datePicker, int i, int i1, int i2) {
                        date = i2 + "/" + i1 + "/" + i;
                        Toast.makeText(c, date, Toast.LENGTH_LONG).show();
                    }
                }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
        datePickerDialog.show();

        return date;
    }

    public static String timePickerDialog(Context context)
    {
        c = context;
        TimePickerDialog timePickerDialog = new TimePickerDialog(c,
                new TimePickerDialog.OnTimeSetListener() {
                    @Override
                    public void onTimeSet(TimePicker timePicker, int i, int i1) {
                        time = i + " : " + i1;
                        Toast.makeText(c, time, Toast.LENGTH_LONG).show();
                    }
                }, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), false);
        timePickerDialog.show();

        return time;
    }
}
İbrahim
  • 991
  • 1
  • 10
  • 32
  • 1
    Give an example of such a method. And tell where the java file resides. – greenapps Jan 19 '17 at 15:44
  • 1
    http://stackoverflow.com/questions/5198105/calling-a-java-method-from-c-in-android – greenapps Jan 19 '17 at 15:46
  • I edited my question. Also I want to call other my Java codes. – İbrahim Jan 19 '17 at 16:34
  • Embarcadero has a JNI Bridge framework to provide access to Java APIs. There is a [`Java2Op`](http://docwiki.embarcadero.com/RADStudio/en/Java2OP.exe,_the_Native_Bridge_File_Generator_for_Android) tool to generate wrappers (that are usable in both Delphi and C++) for any Java APIs that [Embarcadero has not already wrapped](http://docwiki.embarcadero.com/RADStudio/Berlin/en/Using_the_Built-in_RAD_Studio_Java_Libraries_for_Android). – Remy Lebeau Jan 19 '17 at 21:33
  • Also see [Using a Custom Set of Java Libraries In Your RAD Studio Android Apps](http://docwiki.embarcadero.com/RADStudio/en/Using_a_Custom_Set_of_Java_Libraries_In_Your_RAD_Studio_Android_Apps) – Remy Lebeau Jan 19 '17 at 21:33

0 Answers0