mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-04-28 20:27:58 +03:00
62 lines
1.8 KiB
Java
62 lines
1.8 KiB
Java
package android.app;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.IntentSender;
|
|
import android.os.Bundle;
|
|
import android.os.Parcelable;
|
|
|
|
public class PendingIntent implements Parcelable {
|
|
|
|
private int requestCode;
|
|
Intent intent;
|
|
int type; // 0: activity, 1: service, 2: broadcast
|
|
|
|
private PendingIntent(int requestCode, Intent intent, int type) {
|
|
this.requestCode = requestCode;
|
|
this.intent = intent;
|
|
this.type = type;
|
|
}
|
|
public static PendingIntent getBroadcast(Context context, int requestCode, Intent intent, int flags) {
|
|
return new PendingIntent(requestCode, intent, 2);
|
|
}
|
|
|
|
public IntentSender getIntentSender() {
|
|
return null;
|
|
}
|
|
|
|
public void send(Context context, int code, Intent intent) {}
|
|
|
|
public void send() {
|
|
Context context = Context.this_application;
|
|
if (type == 0) { // type Activity
|
|
context.startActivity(intent);
|
|
} else if (type == 1) { // type Service
|
|
context.startService(intent);
|
|
} else if (type == 2) { // type Broadcast
|
|
context.sendBroadcast(intent);
|
|
}
|
|
}
|
|
|
|
public static PendingIntent getActivity(Context context, int requestCode, Intent intent, int flags) {
|
|
return new PendingIntent(requestCode, intent, 0);
|
|
}
|
|
|
|
public static PendingIntent getService(Context context, int requestCode, Intent intent, int flags) {
|
|
return new PendingIntent(requestCode, intent, 1);
|
|
}
|
|
|
|
public static PendingIntent getActivities(Context context, int requestCode, Intent[] intents, int flags, Bundle options) {
|
|
return new PendingIntent(requestCode, intents[0], 0);
|
|
}
|
|
|
|
public String toString() {
|
|
return "PendingIntent [requestCode=" + requestCode + ", intent=" + intent + ", type="
|
|
+ new String[] { "activity", "service", "broadcast" }[type] + "]";
|
|
}
|
|
|
|
public void cancel() {}
|
|
|
|
public class CanceledException extends Exception {
|
|
}
|
|
}
|