开发者

How to call a method using intent

Is there a开发者_Python百科ny possible way to call a method at the time when call the intent activity. I want to display only particular method when i switch over from one activity to another using intent call.


Use the extras bundle in the Intent.

Intent i = new Intent(...);
i.putExtra("your_condition", int_condition);

Then on onCreate of the Intent

int_condition=getIntent.getIntExtra("your_condition");

Now you can use this

if(int_condition==0)
{
//Call the method
}
else
{
//method you want
}

Again there is another option for you as you can pass the method name as a parameter in your Intent, assumes that you are sending mathod_name as an extra to the Bundle

String method_name=getIntent.getIntExtra("method_name");
Class<?> c = Class.forName("class name");
Method  method = c.getDeclaredMethod (method_name, parameterTypes)
method.invoke (objectToInvokeOn, params)


Not exactly sure what your asking ... but this intent will call someone

For example

Intent i = new Intent("android.intent.action.CALL", 
ContentURI.create("tel:" + phone)); 
startActivity(i); 

You have to have the

<uses-permission id="android.permission.CALL_PHONE" /> 

Otherwise send your probelm clearly. i am not able to inderstand

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜