Page 1 of 1

Import issues in java code

Posted: Fri May 09, 2014 4:21 pm
by Geraint Deadman

I am trying to use some imported Java code:

import android.support.v7.app.ActionBarActivity;
import android.telephony.SmsManager;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import android.os.Bundle;

public class MainActivity extends ActionBarActivity {
Button btnSOS;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);
btnSOS =(Button)findViewById(R.id.btnSOS);
btnSOS.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v)
{
sendSMS("+442033226145","SOS Request!");

Log.i("SOS", "Request Sent!");
Toast.makeText(MainActivity.this, "Your Clicked SOS", Toast.LENGTH_LONG)
.show();
}

private void sendSMS(String phoneNumber, String message)
{
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, null, null);

}
});

}

}

that will send a message to a predefined number with a predefined message, but it it is finding the imports part of the code and Import is only available in ES6, can you point me in the right direction or help me to resolve these problems.

Many thanks guys
Image


Import issues in java code

Posted: Fri May 09, 2014 4:24 pm
by Kateryna Grynko

Hi Geraint,

You cannot use Java code in Appery.io.