Tag: android intent

我如何从一个非Activity类启动一个Activity?

我有一个地图视图活动,显示几个OverlayItems 。 在叠加层的onTap方法中,例如,我想要触发一个新的活动,将此叠加层照片显示为全屏。 当我在覆盖类中执行此操作时: Intent intent = new Intent(); intent.setClass(getApplicationContext, FullscreenView.class); startActivity(intent); ..它不能find一个应用程序的上下文,因为我不在一个活动的范围。 当我添加一个方法到我的主要活动,让我们说startFullscreen : public static void startFullscreen() { if (sCurrentPhoto != null) { Intent intent = new Intent(); intent.setClass(getApplicationContext(), FullscreenView.class); startActivity(intent); } } 我无法调用getApplicationContext()和startActivity() ,因为我处于静态上下文中。 然而,我需要静态方法来在Overlay类(如MainView.startFullscreen()调用它。 简单地说: 如何从非Activity类启动一个Activity?

PendingIntent上使用了什么“requestCode”?

背景: 我正在使用PendingIntent通过AlarmManager进行报警。 问题: 起初我以为要取消以前的那个,我必须提供我以前用过的确切的requestCode来启动报警。 但后来我发现我错了,因为取消API说: 使用匹配的意图删除任何警报。 任何types的意图匹配此警报(由filterEquals(Intent)定义)的警报将被取消。 看“ filterEquals ”,文档说: 确定两个意图是否相同意图解决(过滤)的目的。 也就是说,如果他们的行为,数据,types,类别和类别是相同的。 这并不比较意图中包含的任何额外数据。 所以我没有得到什么“requestCode”是… 问题是: 什么是“requestCode”用于? 如果我使用相同的“requestCode”创build多个警报怎么办? 他们互相覆盖吗?

使用Intent.putExtra发送数组

我在活动A中有一个整数数组: int array[] = {1,2,3}; 我想把这个variables发送给活动B,所以我创build了一个新的intent并使用putExtra方法: Intent i = new Intent(A.this, B.class); i.putExtra("numbers", array); startActivity(i); 在BI活动中获取信息: Bundle extras = getIntent().getExtras(); int arrayB = extras.getInt("numbers"); 但是这不是真的发送数组,我只是在arrayB上得到值“0”。 我一直在寻找一些例子,但我没有发现任何东西。

Android:将数据(额外)传递给一个片段

我是Android编程新手,在将一个Parcelable的ArrayList传递给一个片段时遇到了问题。 这是启动的Activity(运行良好!),其中feedlist是可分段音乐的ArrayList。 Intent in = new Intent(context, ListMusicsActivity.class); in.putExtra("arrayMusic", feedList); activity.startActivity(in); Activity的onCreate()方法片段: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activitymusiclist); if(savedInstanceState != null) { ListMusicFragment frag = new ListMusicFragment(); frag.setArguments(getIntent().getExtras()); } } 代码片段: public class ListMusicFragment extends SherlockFragment{ private ArrayList<Music> listMusics = new ArrayList<Music>(); private ListView listMusic; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle […]

所有的Android广播意图列表在哪里

我想收到Android广播消息。 有没有一个意向清单?

popup软键盘时滚动页面

我有一个<ScrollView>布局: <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/my_scrollview" android:layout_width="fill_parent" android:layout_height="wrap_content" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <EditText android:id="@+id/input_one" android:layout_width="300dp" android:layout_height="wrap_content" android:layout_gravity="center" android:inputType="number" > <EditText android:id="@+id/input_two" android:layout_width="300dp" android:layout_height="wrap_content" android:layout_gravity="center" android:inputType="number" > <EditText android:id="@+id/input_three" android:layout_width="300dp" android:layout_height="wrap_content" android:layout_gravity="center" android:inputType="number" > <Button android:id="@+id/ok_btn" android:layout_width="200dp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginTop="20dp" android:text="@string/ok_str" /> </LinearLayout> </ScrollView> 如上所示,简单的布局由三个input字段和一个“确定”button组成。 我用上面的布局运行我的应用程序,当我点击第一个input字段( @+id/input_one ),软键盘将从屏幕底部popup,它隐藏第三个input字段和“确定”button。 由于我使用了<ScrollView> ,我以为可以向上滚动页面以查看软键盘隐藏的第三个input字段和“确定”button, 但页面不可滚动 。 为什么? […]

Android在视图之间绘制一条水平线

我有我的布局如下所示: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/textView1" style="@style/behindMenuItemLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:text="Twitter Feeds" android:textStyle="bold" /> <ListView android:id="@+id/list" android:layout_width="350dp" android:layout_height="50dp" /> <TextView android:id="@+id/textView1" style="@style/behindMenuItemLabel1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="1dp" android:text="FaceBook Feeds" /> <ListView android:id="@+id/list1" android:layout_width="350dp" android:layout_height="50dp" /> </LinearLayout> 我的要求是在TextView和ListView之间绘制一条水平线 谁能帮忙?

如何在Android上以“提供反馈”模式启动Google Play意图?

我刚刚为Google Play商店写了一个游戏,并想提醒我的客户留下有关该应用程序市场的反馈(特别是演示版)。 有什么方法可以启动市场意图的模式,将用户带到页面的反馈/评论部分? 我已经使用这种方法将演示链接到付费应用程序… Intent goToMarket = null; goToMarket = new Intent( Intent.ACTION_VIEW, Uri.parse("market://details?id=com.paulmaidment.games.flagsoftheworld")); startActivity(goToMarket); 有最佳做法吗? 此外,有没有办法跟踪我的演示应用程序的推荐,以便我可以尝试计算某种转换率? (也就是说,演示应用程序在产生销售方面的效果如何)。

使用startActivityForResult,如何获取子活动中的requestCode?

我有四个活动,说A,B,C和D.我的情况是A将通过startActivityForResult启动活动B. startActivityForResult(new Intent(this,B.class),ONE); 在其他情况下,我会B与其他情况。 喜欢 startActivityForResult(new Intent(this,B.class),TWO); 在B我需要检查我需要调用C或D取决于requestCode。 即如果一个需要启动C else D所以我需要知道谁在子Activity(B这里)检查requestCode 或者换句话说,我想知道B在B中开始的请求代码

getIntent()其他总是NULL

我写了一个简单的Android应用程序,显示一个自定义通知像这样: Context context = getApplicationContext(); NotificationManager manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); Notification notification = new Notification( R.drawable.icon, title, System.currentTimeMillis()); Intent notificationIntent = new Intent( context, this.getClass()); notificationIntent.putExtra("com.mysecure.lastpage", "SECURECODE"); PendingIntent pendingIntent = PendingIntent.getActivity( context , 0, notificationIntent, 0); notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT; notification.contentView = new RemoteViews(context.getPackageName(), R.layout.notifypbar); notification.contentIntent = pendingIntent; notification.contentView.setTextViewText(R.id.notifypb_status_text, text); notification.contentView.setProgressBar(R.id.notifypb_status_progress, 100, (int)(100*progress), false); manager.notify(104, […]