Tag: android intent

意图 – 如果活动正在运行,把它放在前面,否则启动一个新的(从通知)

我的应用程序有通知,显然,没有任何标志,每次都会开始一个新的活动,所以我得到了多个相同的活动在彼此之上运行,这是错误的。 我希望它做的是将通知中指定的活动挂起来的意图,如果它已经在运行,否则启动它。 到目前为止,我有这个通知的意图/待决意图是 private static PendingIntent prepareIntent(Context context) { Intent intent = new Intent(context, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); } 奇怪的是,它有时是有效的,有时候不会…我觉得我已经尝试了每一个标志的组合。

如何通过传递一些参数来启动一个意图?

我想在我的ListActivity的构造函数中传递一些variables 我通过这个代码开始活动: startActivity(new Intent (this, viewContacts.class)); 我想使用类似的代码,但要传递两个string的构造函数。 怎么可能?

Parcelable遇到IOException写入可序列化的对象getactivity()

所以我得到这个logcat: java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.resources.student_list.Student) 我知道这意味着我的学生课不是可序列化的,但是,这是我的学生课: import java.io.Serializable; public class Student implements Comparable<Student>, Serializable{ private static final long serialVersionUID = 1L; private String firstName, lastName; private DSLL<Grade> gradeList; public Student() { firstName = ""; lastName = ""; gradeList = new DSLL<Grade>(); } public String getFirstName() { return firstName; } […]

PendingIntent不发送意图额外

我的MainActicity启动了一个带有一个名为isNextWeek的boolean额外的Intent RefreshService 。 我的RefreshService进行Notification ,当用户点击它时启动我的MainActivity 。 这看起来像这样: Log.d("Refresh", "RefreshService got: isNextWeek: " + String.valueOf(isNextWeek)); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.putExtra(MainActivity.IS_NEXT_WEEK, isNextWeek); Log.d("Refresh", "RefreshService put in Intent: isNextWeek: " + String.valueOf(notificationIntent.getBooleanExtra(MainActivity.IS_NEXT_WEEK,false))); pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); builder = new NotificationCompat.Builder(this).setContentTitle("Title").setContentText("ContentText").setSmallIcon(R.drawable.ic_notification).setContentIntent(pendingIntent); notification = builder.build(); // Hide the notification after its selected notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(NOTIFICATION_REFRESH, […]

通过ACTION_SEND在Android App上分享Facebook上的文本

我有一个Android应用程序,它支持通过其他应用程序发送文本。 因此它使用ACTION_SEND intent和EXTRA_TEXT字段。 select器向我展示了可以处理这种意图的所有应用程序。 那些是Twitter,EMail,…和Facebook。 但是当我selectFacebook时,它会打开浏览器并转到以下页面: http://m.facebook.com/sharer.php?u=mytext 它显示我的文本和提交button。 但是当我按下提交button什么都没有发生。 该页面只是再次加载。 我想也许只能通过Facebook应用程序发送URL。 那可以吗? 有没有人设法通过Facebook Android应用程序通过ACTION_SEND发送文本?

sendStickyBroadcast和sendBroadcast在Android中有什么区别?

sendStickyBroadcast和sendBroadcast在Android中有什么区别?

gen已经存在,但不是源文件夹

我正在开发我的Android项目,当我删除一个未使用的库后,我得到了错误: myproject/gen already exists but is not a source folder. Convert to a source folder or rename it 在我的活动代码中,来自R.java所有资源都无法parsing。 我试了,右键点击我的项目=> Java Build Path =>在“Source”选项卡下,我添加了gen /作为源。 但是这对问题没有帮助 为什么,如何摆脱这个问题? —- —-更新 我发现,日食也抱怨说:“项目没有project.properties文件!编辑项目属性设置一个。 ,但我的项目下有project.properties文件。 为什么抱怨? 我已经清理了这个项目并“修复了项目属性”,但是没有帮助。

onNewIntent()生命周期和注册监听器

我正在使用oneTop Activity通过onNewIntent()从search对话框接收意图。 我注意到onPause()在onNewIntent()之前onNewIntent() ,然后调用onResume() 。 视觉: search对话框启动 search意图激发到活动 onPause() onNewIntent() onResume() 问题是我在onResume()中注册了监听器,在onPause()中被移除,但是在onNewIntent()调用中需要它们。 有没有一个标准的方法来使这些听众可用?

没有animation的切换活动

我如何正确使用AndroidManifest文件中的Intent标志FLAG_ACTIVITY_NO_ANIMATION ? 我认为我的问题是微不足道的,但我找不到很好的例子或解决scheme。 <intent-filter> <data android:name="android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION" /> </intent-filter> 然而,compliator没有报告错误,但data不正确。 我只是想在动作切换的情况下禁用animation。 我可以使用getWindow().setWindowAnimations(0); 在onCreate或onResume,而是使用标志是更好的方式,不是吗? 我也可以在代码中使用: Intent intent = new Intent(v.getContext(), newactivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); getContext().startActivity(intent); 但是我想在Android Manifest中使用这个标志。 如果从第二个活动返回到第一个,也禁用animation。

启动短信应用程序的意图

我有一个意图的问题…我尝试启动短信应用程序… Intent intent = new Intent(Intent.ACTION_MAIN); intent.setType("vnd.android-dir/mms-sms"); int flags = Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP; intent.setFlags(flags); intent.setData(Uri.parse("content://sms/inbox")); context.startActivity(intent); 所以,你可以看到我把太多东西放在我的意图中,但那是因为我不知道该怎么办…谢谢