Skip to content

Commit 357800e

Browse files
committed
Main, flags, multi-activity
1 parent 1058b29 commit 357800e

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/action.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// Action to invoke with an intent
22
pub enum Action {
3+
Main,
34
Send,
45
Edit,
56
Chooser,
@@ -8,6 +9,7 @@ pub enum Action {
89
impl AsRef<str> for Action {
910
fn as_ref(&self) -> &str {
1011
match self {
12+
Self::Main => "ACTION_MAIN",
1113
Self::Send => "ACTION_SEND",
1214
Self::Edit => "ACTION_EDIT",
1315
Self::Chooser => "ACTION_CHOOSER",

src/intent.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<'vm, 'env> Intent<'vm, 'env> {
8585
///
8686
/// # android_intent::with_current_env(|env| {
8787
/// let intent = Intent::new(env, Action::Send)
88-
/// .set_class_name("com.excample", "IntentTarget");
88+
/// .set_class_name("com.example", "IntentTarget");
8989
/// # })
9090
/// ```
9191
pub fn set_class_name(
@@ -191,9 +191,23 @@ impl<'vm, 'env> Intent<'vm, 'env> {
191191
})
192192
}
193193

194-
pub fn start_activity(self) -> Result<(), Error> {
195-
let cx = ndk_context::android_context();
196-
let activity = unsafe { JObject::from_raw(cx.context() as jni::sys::jobject) };
194+
pub fn add_flags(self, flags: i32) -> Self {
195+
self.and_then(|inner| {
196+
inner.env.call_method(
197+
&inner.object,
198+
"addFlags",
199+
"(I)Landroid/content/Intent;",
200+
&[JValue::Int(flags)],
201+
)?;
202+
203+
Ok(inner)
204+
})
205+
}
206+
207+
pub fn start_activity(self, activity: JObject) -> Result<(), Error> {
208+
// let cx = ndk_context::android_context();
209+
// let activity = unsafe { JObject::from_raw(cx.context() as jni::sys::jobject) };
210+
// let activity = unsafe { JObject::from_raw(cx.context() as jni::sys::jobject) };
197211

198212
self.inner.and_then(|inner| {
199213
inner.env.call_method(

0 commit comments

Comments
 (0)