小编Dip*_*iya的帖子

如何检查edittext的文本是否是电子邮件地址?

如何在edittext不使用javascript正则表达式的情况下检查电子邮件地址的文本?在这里我使用inputtype="textEmailAddress"它是工作但没有显示错误消息.

android email-validation android-edittext

110
推荐指数
6
解决办法
11万
查看次数

Android TabWidget检测单击当前选项卡

当此选项卡是当前选项卡时,我正试图找到能够在选项卡上触发onclick事件的方法.

我确实尝试过这种方式(在其他几种方式中)并没有成功.

public void onTabChanged(String tabId) {
    Log.d(this.getClass().getName(), ">>>>>>>>>>>>>>>>>>>>>>>> tabId: " + tabId);

    int tabs = getTabWidget().getChildCount();
    Log.d(this.getClass().getName(), "tabs: " + tabs);
    for(int i=0; i<tabs; i++){
        View tab = getTabWidget().getChildAt(i);
        if(i==tabHost.getCurrentTab()){
            Log.d(this.getClass().getName(), "tab: " + i);
            tab.setOnClickListener(this);
        }else{
            tab.setOnClickListener(null);
            tab.getOnFocusChangeListener();
        }
    }   
}
Run Code Online (Sandbox Code Playgroud)

关键是我设置为onClickListener,null所以下次单击选项卡时没有任何反应,但我希望有正常的选项卡行为.

外面有什么想法吗?

android listener tabwidget android-tabhost

36
推荐指数
5
解决办法
7万
查看次数

在android sqlite中选择不同的值

我尝试在android中运行以下原始查询,似乎不起作用

String query ="SELECT DISTINCT category FROM event";
Cursor  cursor = mDb.rawQuery(query, null);
if (cursor != null) {
     cursor.moveToFirst();
}
return cursor; 
Run Code Online (Sandbox Code Playgroud)

所以我决定在android中使用query()方法

Cursor mCursor = mDb.query(EVENT_TABLE, new String[] {KEY_ROWID, KEY_CAT}, null, null,null,null, null)
Run Code Online (Sandbox Code Playgroud)

任何人都可以告诉我如何选择使用query()而不是rawquery的不同类别,任何帮助将不胜感激!

sqlite android

32
推荐指数
3
解决办法
4万
查看次数

java.lang.SecurityException:需要Jelly Bean 4.2的VIBRATE权限

从昨天起我在Android 4.2上遇到问题,当我收到推送通知时,即使我没有将其设置为振动,也需要获得许可

Notification notification = new Notification(icon, notificationItem.message, when);
notification.setLatestEventInfo(context, "App", notificationItem.message,
            PendingIntent.getActivity(context, 0, intent, 0));
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;

NotificationManager nm =
            (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(notificationItem.notificationID, notification);
Run Code Online (Sandbox Code Playgroud)

nm.notify引发了异常

我在两个不同的应用程序中遇到此问题,我从不修改代码

notifications android push android-4.2-jelly-bean

32
推荐指数
3
解决办法
2万
查看次数

在Android中下载并解压缩Zip文件

我的应用程序是从服务器下载zip文件并提取此zip文件并将文件保存到SD卡但问题是,如果我下载4-5 MB的zip文件并解压缩,这是工作正常,但如果我正在下载30-35 MB zip文件这会给我错误,抱歉我的英语沟通不好.

下面是我的下载和解压缩Zip文件的代码: -

public class UnzipManager {
    private static String BASE_FOLDER;

    public static Context localContext;
    public static String passurl;
    public static int count;
    public static Context context;
    /*
     * You can use this flag to check whether Unzippingthread is still running..
     */
    public static boolean isDownloadInProgress;
    /*
     * After unzipping using this flag ,you can check whether any low memory
     * exceptions Occurred or not..and alert user accordingly..
     */
    public static boolean isLowOnMemory;
    public static int i …
Run Code Online (Sandbox Code Playgroud)

android unzip download

27
推荐指数
2
解决办法
7万
查看次数

HTC Thunderbolt上的Android Email Multiple Attachment问题

我这里有一个奇怪的情况.

我正在尝试使用以下代码发送带有多个附件的电子邮件.

Intent emailIntent = new Intent( android.content.Intent.ACTION_SEND_MULTIPLE );
// emailIntent.setType( "plain/text" );
emailIntent.setType( "application/octet-stream" );
...
....
emailIntent.putParcelableArrayListExtra( Intent.EXTRA_STREAM, uris );
Run Code Online (Sandbox Code Playgroud)

这很好用,隐式意图机制显示了很多选项,如Gmail,Skype,Messaging等.

问题是默认的Mail客户端没有显示在HTC Thunderbolt上(但适用于其他设备,包括HTC Incredible S).

如果我尝试使用发送单个附件Intent.ACTION_SEND,则会显示默认邮件客户端.我已经尝试将内容类型设置为text/plain,appliation/octet-stream,message/rfc282等但是没有效果.

我在这里错过了什么?

android email-attachments android-intent htc-thunderbolt

24
推荐指数
1
解决办法
614
查看次数

如何将结果从第二个片段传递到第一个片段

在我的应用程序中,我有两个片段,分别是fragmentAFragmentB.当我点击fragmetA中的按钮时,会在fragmentB中打开一个列表.现在,当我从fragmentB中的列表中选择一个项目时,我希望将结果传递给fragmentA.我只对所有片段使用一个TabActivity.当在fragmentB中选择列表项时,我从堆栈中弹出fragmentB,这样我就可以直接返回fragmentA了.

有谁知道如何将结果传递给以前的片段.

谢谢.

android android-fragments

24
推荐指数
2
解决办法
2万
查看次数

在WebViewClient中覆盖shouldInterceptRequest时系统崩溃

目标:

覆盖WebView发出的所有请求并自行发出请求(最终设置代理).

码:

@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    if (url == null || url.trim().equals(""))
        return null;

    final DefaultHttpClient httpClient = new DefaultHttpClient();
    httpClient.getConnectionManager().closeExpiredConnections();
    final HttpUriRequest httpRequest = new HttpGet(url);

    try {
        final HttpResponse response = httpClient.execute(httpRequest);
        final Header[] headers = response.getHeaders(CONTENT_TYPE);
        String mimeType = "";
        String encoding = "";
        if (headers != null && headers.length > 0) {
            final String type = headers[0].getValue();
            final int semicolonIndex = type.indexOf(';');
            if (semicolonIndex != -1) {
                mimeType = type.substring(0, semicolonIndex).trim(); …
Run Code Online (Sandbox Code Playgroud)

android webview android-webview webviewclient

19
推荐指数
1
解决办法
2364
查看次数

一个AndroidManifest.xml中的两个searchable.xml活动

我有一个Android应用程序,它有一些不同的活动,用于浏览从RSS下载的文章和图像.

我希望能够使用a 文件将搜索按钮连接到"搜索"对话框searchable.xml.我通过一次搜索设法做到了这一点,使用:

<activity android:name=".search.SearchResultsActivity"
    android:label="@string/search_results_activity_title" >
    <intent-filter>
        <action android:name="android.intent.action.SEARCH" />
    </intent-filter>
    <meta-data android:name="android.app.searchable"
        android:resource="@xml/searchable_articles"/>
</activity>
Run Code Online (Sandbox Code Playgroud)

并在 <application />

<meta-data android:name="android.app.default_searchable"
    android:value=".search.SearchResultsActivity" />
Run Code Online (Sandbox Code Playgroud)

我现在可以从任何活动启动"搜索"对话框,然后启动SearchResultsActivity.

我现在希望能够在用户ImageListActivity使用a 时搜索图像searchable_images.xml,并在其他任何地方使用默认值.

我有一个SearchResultsImageActivity包含以下元数据元素,并使用相同的元素ImageListActivity.

<meta-data android:name="android.app.searchable"
    android:resource="@xml/searchable_images"/>
Run Code Online (Sandbox Code Playgroud)

按下搜索按钮ImageListActivity,我得到默认搜索searchable_articles.xml.

如果我更改default_searchableSearchResultsImageActivity,则始终启动图像搜索,并且永远不会启动文章搜索.

如果我完全删除default_searchable元数据元素,并searchable仅添加选定活动的元数据,则不会启动搜索.

我很确定这应该是可能的,但我不知道我做错了什么.

search android android-manifest searchable

17
推荐指数
2
解决办法
4286
查看次数

如何使用intent停止android中的活动?

我认为这是一个基本问题.是否有任何选项可以通过使用intent来停止活动.

Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:5554"));
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

这是我的代码.如果用户忙或什么的话,我想停止这个活动(这意味着,我想放弃这个电话).我能做些什么?我试过这个:

if (condition) {
    Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:5554"));
    startActivity(intent);
}else {
    this.finish();
}
Run Code Online (Sandbox Code Playgroud)

但没有用.有人有建议吗?

android android-intent

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