Facing error with Intent

Hello Guys,
i am facing errors in my code

@SimpleFunction(description = "")
public void SendMail(String to, String subject, String mailText){
    String a = "mailto:";
    String b = "?subject=";
    String c = "&body=";
    String url = a+to+b+subject+c+mailText;
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(url));
    startActivity(intent);

}

ERROR LOG :-

[javac] D:\vedang\extension-template-master\src\com\extensions\randomimg\RandomImg.java:42: error: cannot find symbol
[javac] startActivity(intent);
[javac] ^

Do you need a code for this?

1 Like

wait that was my deleted topic.

now see. i am facing a error @Salman_Dev

Maybe this code can help you :
startActivity(new Intent(Intent.ACTION_VIEW, [Uri.parse](http://Uri.parse)("https://site.ru")));

https://www.tutorialspoint.com/sending-an-intent-to-browser-to-open-specific-url-in-android
i have seen this tutorial but it is diffrent than your code still i will try btw thanks

If my code is successful, please let me know :grin:

no

I think I know the problem in the code.
wait a minute I will fix the code for

where is the problem ?

You don't have an intent name

Try the code that I fixed:

 @SimpleFunction(description = "")
    public void SendMail(String to, String subject, String mailText){
        String a = "mailto:";
        String b = "?subject=";
        String c = "&body=";
        String url = a+to+b+subject+c+mailText;
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        startActivity(i);

    }

lol what is the difference between your code and my code

only slightly different :grin:

you just changed name of Intent

still same error

[javac] D:\vedang\extension-template-master\src\com\extensions\randomimg\RandomImg.java:44: error: cannot find symbol
[javac] startActivity(i);

Hmm, :thinking:

Try this new code :

 @SimpleFunction(description = "")
    public void SendMail(String to, String subject, String mailText){
        String a = "mailto:";
        String b = "?subject=";
        String c = "&body=";
        String url = a+b+c;
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        startActivity(i);

    }

its old tried but same errors

I will try to find the code for you

1 Like