| 143 | } |
| 144 | |
| 145 | Result OpenURL(const char* url, const char* target) |
| 146 | { |
| 147 | if (*url == 0x0) |
| 148 | { |
| 149 | return RESULT_INVAL; |
| 150 | } |
| 151 | |
| 152 | dmAndroid::ThreadAttacher thread; |
| 153 | JNIEnv* env = thread.GetEnv(); |
| 154 | if (!env) |
| 155 | { |
| 156 | return RESULT_UNKNOWN; |
| 157 | } |
| 158 | |
| 159 | jclass uri_class = env->FindClass("android/net/Uri"); |
| 160 | jstring str_url = env->NewStringUTF(url); |
| 161 | jmethodID parse_method = env->GetStaticMethodID(uri_class, "parse", "(Ljava/lang/String;)Landroid/net/Uri;"); |
| 162 | jobject uri = env->CallStaticObjectMethod(uri_class, parse_method, str_url); |
| 163 | env->DeleteLocalRef(str_url); |
| 164 | if (uri == NULL) |
| 165 | { |
| 166 | return RESULT_UNKNOWN; |
| 167 | } |
| 168 | |
| 169 | jclass intent_class = env->FindClass("android/content/Intent"); |
| 170 | jfieldID action_view_field = env->GetStaticFieldID(intent_class, "ACTION_VIEW", "Ljava/lang/String;"); |
| 171 | jobject str_action_view = env->GetStaticObjectField(intent_class, action_view_field); |
| 172 | jmethodID intent_constructor = env->GetMethodID(intent_class, "<init>", "(Ljava/lang/String;Landroid/net/Uri;)V"); |
| 173 | jobject intent = env->NewObject(intent_class, intent_constructor, str_action_view, uri); |
| 174 | if (intent == NULL) |
| 175 | { |
| 176 | return RESULT_UNKNOWN; |
| 177 | } |
| 178 | |
| 179 | jclass activity_class = env->FindClass("android/app/NativeActivity"); |
| 180 | jmethodID start_activity_method = env->GetMethodID(activity_class, "startActivity", "(Landroid/content/Intent;)V"); |
| 181 | env->CallVoidMethod(thread.GetActivity()->clazz, start_activity_method, intent); |
| 182 | jthrowable exception = env->ExceptionOccurred(); |
| 183 | env->ExceptionClear(); |
| 184 | if (exception != NULL) |
| 185 | { |
| 186 | return RESULT_UNKNOWN; |
| 187 | } |
| 188 | |
| 189 | return RESULT_OK; |
| 190 | } |
| 191 | |
| 192 | Result GetResourcesPath(int argc, char* argv[], char* path, uint32_t path_len) |
| 193 | { |
nothing calls this directly
no test coverage detected