File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,31 @@ impl<'env> Intent<'env> {
7171 } )
7272 }
7373
74+ /// Set the class name for the intent target.
75+ /// ```no_run
76+ /// use android_intent::{Action, Extra, Intent};
77+ ///
78+ /// # android_intent::with_current_env(|env| {
79+ /// let intent = Intent::new(env, Action::Send);
80+ /// intent.set_class_name("com.excample", "IntentTarget")
81+ /// # })
82+ /// ```
83+ pub fn set_class_name ( self , package_name : impl AsRef < str > , class_name : impl AsRef < str > ) -> Self {
84+ self . and_then ( |inner| {
85+ let package_name = inner. env . new_string ( package_name) ?;
86+ let class_name = inner. env . new_string ( class_name) ?;
87+
88+ inner. env . call_method (
89+ inner. object ,
90+ "setClassName" ,
91+ "(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;" ,
92+ & [ package_name. into ( ) , class_name. into ( ) ] ,
93+ ) ?;
94+
95+ Ok ( inner)
96+ } )
97+ }
98+
7499 /// Add extended data to the intent.
75100 /// ```no_run
76101 /// use android_intent::{Action, Extra, Intent};
You can’t perform that action at this time.
0 commit comments