标签: android-4.0-ice-cream-sandwich

在安卓上的小孩安全app

我有一个应用程序,应该是幼儿安全.这意味着,它可以阻止任何单个按键触摸,但可以处理长按以退出应用程序.这样,幼儿在玩耍时可以安全地做(太)讨厌的事情.直到2.3.4版本,我成功实现了这一目标.但是,现在我有两个问题:

  1. 在蜂窝状态下,我有状态栏通知,可以按下.另外,我有可以按下的开关窗口键.我唯一成功的就是调暗状态栏.
  2. 在冰淇淋三明治(使用模拟器,我仍然没有这个版本的真实设备),当调用下一个代码时,我得到一个甚至无法捕获的异常.例外:

    java.lang.IllegalArgumentException:添加窗口后无法更改窗口类型.

代码:

@Override
public void onAttachedToWindow()
  {
  this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
  super.onAttachedToWindow();
  }
Run Code Online (Sandbox Code Playgroud)

我能做什么?

android key block android-3.0-honeycomb android-4.0-ice-cream-sandwich

6
推荐指数
1
解决办法
7745
查看次数

Theme.Translucent在ICS上失败

我正在使用: android:theme="@android:style/Theme.Translucent.NoTitleBar"

结合: getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

要获得漂亮的透明背景模糊效果,请模拟对话框样式.

这在2.3及以下版本中效果很好,但在运行ICS/3.0及更高版本的设备上它是纯色(读取不透明).我知道他们介绍了一个全息主题,似乎没有一个特定的Theme.Holo.Translucent主题.关于如何在ICS和旧版本上获得半透明背景的任何想法,我不反对使用在值-v11中定义的单独主题.

android themes android-4.0-ice-cream-sandwich

6
推荐指数
1
解决办法
3590
查看次数

从Recent Apps Android 4.x隐藏/更改应用程序屏幕图片

当您单击Android 4.x中的"最近的应用程序"按钮时,我需要从正在运行的应用程序列表中隐藏我的应用程序屏幕.如果有人要让我的应用程序在后台运行,我的应用程序包含的数据可能会泄漏敏感信息.我仍然希望我的应用程序能够在最近的应用程序中显示,而不是屏幕截图.

你怎么做到这一点?

android android-4.0-ice-cream-sandwich android-4.2-jelly-bean android-4.3-jelly-bean

6
推荐指数
1
解决办法
2291
查看次数

搜索正确的AVD设置以模拟Samsung Galaxy Nexus(使用android-4.x,ICS)

我最近升级了我的android沙箱来处理Icecream Sandwich(ICS,又名android-4).不幸的是,我无法找到最新的基于Android的旗舰产品的配置数据; 三星的Galaxy Nexus.

任何人都可以帮助解决具体的配置参数吗?

Regs,Rob

configuration android android-virtual-device android-4.0-ice-cream-sandwich

5
推荐指数
2
解决办法
7787
查看次数

Android 4.0自定义通知,如谷歌音乐

我想创建一个带有进度条和删除按钮的自定义通知.

截图:

在此输入图像描述

我成功创建了带有进度条的自定义通知,但我没有设法创建删除事件.我想取消通知并在用户点击"x"后停止上传(如在谷歌音乐中,因此我不想启动活动来清除通知).

这是我的工作代码:

    notificationManager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);

    int icon = R.drawable.ic_launcher;
    CharSequence tickerText = "Hello";
    long when = System.currentTimeMillis();

    notification = new Notification(icon, tickerText, when);    


    CharSequence contentTitle = "My notification";
    CharSequence contentText = "Hello World!";
    Intent notificationIntent = new Intent(context, UploadEventsReceiver.class);
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

    notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
    notification.contentView = new RemoteViews(context.getPackageName(), R.layout.upload_progress);
    notification.contentView.setOnClickPendingIntent(R.id.text, contentIntent);

    notificationManager.notify(this.notificationId, notification);
Run Code Online (Sandbox Code Playgroud)

在线

Intent notificationIntent = new Intent(context, UploadEventsReceiver.class);
Run Code Online (Sandbox Code Playgroud)

我尝试使用没有"广播"的BroadCast接收器,但我不知道这是否是正确的方法,我没有成功使其工作.我应该使用什么以及如何使用它?

notifications android android-4.0-ice-cream-sandwich

5
推荐指数
1
解决办法
2639
查看次数

如何通过附加按钮从自定义丰富通知中关闭Android> = 3.0中的通知下拉菜单?

I successfully created a custom rich notification for Android >= 3.0 that shows some text and an additional button. If you click the notification anywhere but on the button in the notification drop-down, the notification is dismissed, the drop-down closed and the specified Intent is launched as expected. If the dedicated button in the notification is clicked, a different Intent is successfully launched, but the drop-down keeps open (and the notification is still there, but I cancel it later, that …

notifications android android-3.0-honeycomb android-4.0-ice-cream-sandwich

5
推荐指数
1
解决办法
1087
查看次数

我的应用程序适用于Android 2.3.3到Android 3.1但在4.0 +上停止错误

我刚刚公开了我的第一个Android应用程序.我没有在Android 4.0上测试过,我的朋友告诉我我的应用程序在他的银河系S2(4.0.3)崩溃

它在我的启动画面活动中几秒钟后崩溃,它只需几行代码就可以查看它们:

 @Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splashscreen);

    try
    {

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    overridePendingTransition(0 , 0);

    // thread for displaying the SplashScreen
    Thread splashTread = new Thread() {
        @Override
        public void run() {
            try {
                int waited = 0;
                while(_active && (waited < _splashTime)) {
                    sleep(100);
                    if(_active) {
                        waited += 100;
                    }
                }
            } catch(InterruptedException e) {
                // do nothing
            } finally {
               // finish();

                try
                {
                  /*
                   Intent i = new Intent();
                    i.setClass(SplashScreen.this, MainActivity.class);
                    startActivity(i);
                    finish();
                    */
                } …
Run Code Online (Sandbox Code Playgroud)

crash android splash-screen android-4.0-ice-cream-sandwich

5
推荐指数
3
解决办法
2474
查看次数

Galaxy Nexus上没有显示背景图片(仅限)?

这里非常特殊的问题,简单的背景图像资产将在除Galaxy Nexus之外的所有手机上显示正常(或者我到目前为止已找到)

在多个不同的手机中找到应用程序的图库下方,但请注意图像编号SIX中的nexus没有背景?

我已经设置了对所有密度和大+ XL屏幕尺寸的支持,我将发布一个布局的XML,但它跨越所有布局,无论是否有任何控件/线性布局或其他任何.

图片:http://goo.gl/59c8C

<?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent" android:background="@drawable/app_bg">

     <ScrollView
         android:id="@+id/scrollView12"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent" android:layout_alignParentBottom="true" android:fillViewport="true">

         <RelativeLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent" >

                 <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:orientation="vertical" android:layout_alignParentBottom="true">


             <com.quickcontact.CustomTextView
                 android:id="@+id/CustomTextView01"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="10dp"
                 android:gravity="center"
                 android:text="Tap the buttons below to create your contact profiles. You will be able to assign contact details to each of your profiles and share them with others."
                 android:textColor="#3f3f3f"
                 android:textSize="15sp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_gravity="center_horizontal"/>

             <com.quickcontact.CustomTextView
                 android:id="@+id/receiveHeadertxt"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="20dp"
                 android:gravity="center"
                 android:text="-- Create Profile --" …
Run Code Online (Sandbox Code Playgroud)

xml user-interface android background android-4.0-ice-cream-sandwich

5
推荐指数
1
解决办法
2125
查看次数

Android 4中的雅虎货币汇率

在我的申请中,我需要获得不同货币的当前汇率.因为它已经被提出这个,这个这个问题的一个很好的办法做到这一点,是使用雅虎财经服务.

所以,当我想找到例如美元和加元之间的汇率时,我只需发送此链接: http://download.finance.yahoo.com/d/quotes.csv?s=USDCAD=X&f=sl1d1t1ba&e=.csv

这对于我的带有Android 2.3.4的摩托罗拉Atrix手机和再次使用Google API 2.3.3的模拟器都可以正常工作.但是,当我尝试使用Android ICS 4.0的Galaxy SII和使用Google API 4.0的模拟器完全相同的链接时,在两种情况下,quotes.csv文件仅包含"缺失符号列表".

在挖掘之后,我发现如果没有找到费率,就会发生这种反应.但是这个响应是我在Android 4.0(Galaxy SII或模拟器)下尝试的任何货币.因此,我无法使用Android 4.0获得费率,但我可以使用Android 2.x.

有没有人遇到过同样的问题?有没有解决方法?

编辑:这是处理从雅虎货币服务下载费率的线程代码:

//show the progress dialog
downloadingDialog.show();
Runnable getRates = new Runnable() {
   public void run(){
      dataNotFound = false;
      final String baseDir = getApplicationContext().getFilesDir().getAbsolutePath();
      //download the rates from yahoo to a CSV file
      downloadFileViaHTTP (baseDir);
      //read the file line
      String filePath = baseDir + "/" + "quotes.csv";
      Log.d(tag, "-> filePath = " + filePath);
      try {
         // …
Run Code Online (Sandbox Code Playgroud)

android currency yahoo-finance android-4.0-ice-cream-sandwich

5
推荐指数
1
解决办法
1827
查看次数

几秒钟后在Android上捕获事件

我想在Android中为我的应用程序添加一个按钮,并在按下按钮几秒钟后在此按钮(onclick)上捕获事件,因此在第一次触摸时它不会做出反应.这可以在Android上实现吗?

现在我有下一个代码,用于捕获主页按钮上的onclick(在ActionBar中).

public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        showSendLogAlert();
    }

    return super.onOptionsItemSelected(item);
}
Run Code Online (Sandbox Code Playgroud)

当用户点击此按钮时,它会通过电子邮件发送一个小报告,我不想意外地启动此事件,这就是为什么我希望用户按下几秒钟以确保他想要这样做操作.

解:

基于以下评论,我得到了这个有效的解决方案:

@Override
protected void onCreate(final Bundle savedInstanceState) {
    // stuff

    // Set the home button clickable
    getActionBar().setHomeButtonEnabled(true);

    // Define a long click listener instead of normal one
    View homeButton = findViewById(android.R.id.home);
    homeButton.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            showSendLogAlert();
            return false;
        }
    });

    // more stuff
}
Run Code Online (Sandbox Code Playgroud)

android android-4.0-ice-cream-sandwich

5
推荐指数
1
解决办法
1396
查看次数