我这样做是为了创建一个意图。
Intent notificationIntent = new Intent(this, Startup.class);
notificationIntent.putExtra("url", contentUrl);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new Notification(icon, tickerText, when);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
Run Code Online (Sandbox Code Playgroud)
得到额外的钱后,
CharSequence url = this.getIntent().getCharSequenceExtra("url");
Run Code Online (Sandbox Code Playgroud)
有许多 Intent 及其各自的 url 值。但我也在 Startup 类的 onCreate() 中得到了相同的值。
我做错了什么?
我使用以下代码从 Android 应用程序启动默认短信活动以发送短信:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("sms:"));
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
但我想直接在我的EditText包含文本消息的文本中设置一些文本(当我启动默认短信活动时,该文本EditText为空)。我怎样才能做到这一点 ?
问候,
我想将List<String[]>意图传递给活动,然后检索它。有人知道如何正确执行此操作吗?谢谢
当我尝试使用意图从主项目传递到库项目时,它工作正常,但是......当我尝试从库项目传递到主项目时,它无法识别主项目中的类。
我尝试在我的图书馆项目中写下这个意图:
Intent intent = new Intent(this,com.example.uploadvideo.class);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
我将我想要连接的两个活动添加到主项目和库项目的清单中。
我有一个应用程序,可以让用户制作从设备中选择的歌曲列表。然后,他们可以选择要播放的歌曲,应用程序将使用 Intent 打开歌曲的 uri,以便使用默认音乐播放器实际播放歌曲。
\n\n如果我使用 Astro 文件管理器选择歌曲,则效果很好,但如果我通过 google Drive、音频部分或下载部分选择文件,则该歌曲将无法播放。
\n\n我正在选择具有如下意图的文件:
\n\nIntent intent = new Intent(Intent.ACTION_GET_CONTENT);\nintent.setType("audio/*");\nintent = Intent.createChooser(intent, "Select audio or music");\nRun Code Online (Sandbox Code Playgroud)\n\n然后使用 检索 Uri data.getData()。
稍后使用如下意图打开 Uri Im:
\n\nIntent intent = new Intent(Intent.ACTION_VIEW, uri);\ncontext.startActivity(intent);\nRun Code Online (Sandbox Code Playgroud)\n\nAstro 文件管理器以表单返回 Uris file:///storage/sdcard0/Download/My%20Song.mp3,这些文件可以使用默认媒体应用程序打开并正常播放。
Google 云端硬盘以 形式返回 Uris content://com.google.android.apps.docs.storage/document/acc%3D1%3Bdoc%3D421。\n当我尝试使用默认媒体应用程序通过 Intent 打开这样的 Uris 时,它会显示一个弹出窗口“无法播放您请求的曲目”。
如何打开 Google Drive 使用该媒体类型的默认应用程序返回的内容 Uri?
\n\n编辑:我还尝试在使用 Intent 打开 uri 时显式设置 mime 类型:
\n\nIntent intent = new Intent(Intent.ACTION_VIEW, audio.getAudioUri());\nintent.setType("audio/*");\ncontentController.startActivity(intent);\n …Run Code Online (Sandbox Code Playgroud) 你好,我对 Andriod 还很陌生。我有三个活动 AB C。A 是 MainActivity B 和 C 是独立活动。我在 mainActivity 中包含了一个日历,并突出显示了一些日期。
现在通过 mainActivity 我启动一个新的活动 B 并使用以下代码返回到 A
public void OnClick(View V){
Intent i= new Intent(getApplicationContext(),A.class);
i.setFlags(Imtent.FLAG_ACTVITIY_CLEAR_TOP);
startActivity(i);
}
Run Code Online (Sandbox Code Playgroud)
这将返回到 mainActivity,但突出显示的日期不在那里。我想知道是否创建了一个全新的活动,或者我在突出显示这些日子时做错了什么。
我是 firebase 控制台发送通知。它直接向系统托盘发送通知。我想在用户点击它们时从它们那里获取有效负载。
当您的应用程序在后台运行时,Android 会将通知消息定向到系统托盘。默认情况下,用户点击通知会打开应用程序启动器。
这包括包含通知和数据负载的消息(以及从通知控制台发送的所有消息)。在这些情况下,通知将传递到设备的系统托盘,并且数据负载将在启动器活动的意图的附加内容中传递。
https://firebase.google.com/docs/notifications/android/console-audience
我能够获取从控制台发送的通知 如何从我的意图之外获取通知负载?
android android-intent firebase firebase-cloud-messaging firebase-notifications
我创建了一个应用程序,将使用操作发送发送文件,一小时后我的代码不起作用。
当它打开其他应用程序时,我收到一条错误“传输此类内容类型不受支持”,对于 shareIt 和蓝牙文件 iamafile 未发送到...这是我的代码,我尝试了很多代码但不起作用。请帮忙
File root = new File(Environment.getExternalStorageDirectory(), "/QuizApp/MyAnswer/"+sharedPreferenceUsername +"/"+ editTitle);
Uri uri = Uri.fromFile(root);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("*/*");
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
顺便说一下,editTitle 是一个文件。
我想以编程方式退出应用程序。我怎样才能做到这一点 ?
我研究了很多但没有找到任何解决方案,请问有什么建议或示例代码吗?
我的适配器类中有一个按钮。当我点击它时,我想关闭应用程序。我怎样才能做到这一点 ?
这是我在适配器类中的点击事件
public class FooterViewHolder extends ViewHolder {
public FooterViewHolder(View itemView) {
super(itemView);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((MyPageActivity)mContex).finishAffinity();
}
});
}
}
Run Code Online (Sandbox Code Playgroud) I am using this code to send sms:
This code could be found in many tutorials but it is not working in Oreo, i have sent the correct answer
public void sendSms(String phone) {
if(null != phone) {
final Intent i = new Intent(Intent.ACTION_VIEW);
i.setType("vnd.android-dir/mms-sms");//<-- maybe problem is here
i.putExtra("address", phone);
startActivity(Intent.createChooser(i, getString(R.string.sms)));
}
}
Run Code Online (Sandbox Code Playgroud)
I have tested this code in Android 4 to Android 6 and no problem but in Android 8.1 google api emulator says no app can …