小编Boa*_*rdy的帖子

以编程方式清除用户自己的应用数据

我正在开发一个应用程序,我想让用户能够设置,如果他们在几次尝试进入应用程序后失败登录,它将自动删除所有数据,包括首选项和数据库.

是否有一种简单的方法可以执行此操作,还是必须编写代码来手动重置应用程序使用的所有内容?

android

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

在linux中获取文件的上次修改时间

我正在开发一个C程序,我需要获取文件的最后修改时间.程序所做的是一个函数循环遍历目录中的每个文件,当找到特定文件时,它调用另一个函数来检查文件的最后修改时间.

在该目录下有一个mylog.txt.1,mylog.txt.2mylog.txt.3等当我使用ll命令我可以看到,列出目录在linux mylog.txt.1mylog.txt.2进行了修改,在5月4日,并mylog.txt.3于5月3日进行了修改.

但是当程序检查这些文件时,它总是返回第3个.下面是我正在使用的代码.

void getFileCreationTime(char *filePath)
{
    struct stat attrib;
    stat(filePath, &attrib);
    char date[10];
    strftime(date, 10, "%d-%m-%y", gmtime(&(attrib.st_ctime)));
    printf("The file %s was last modified at %s\n", filePath, date);
    date[0] = 0;
}
Run Code Online (Sandbox Code Playgroud)

我已经尝试了所有不同的变化st_ctime,即st_mtime,st_atime但他们都返回第3可能.

感谢您的任何帮助,您可以提供.

c linux timestamp last-modified

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

使用带有片段的上下文操作栏

我目前正在研究android项目并使用片段和ListViews/ListFragments.我有上下文操作栏来处理标准活动,例如ListActivity.

现在我尝试做同样的事情,但在片段布局上.我有一个MainActivity,它扩展了Activity,它为包含2个片段,片段A和片段B的布局扩展了XML.

片段A扩展了ListFragment并包含一个ListView,它从SQLite数据库中的数据填充.当我有一个上下文操作栏上的标准ListActivity工作,我有一个扩展ListView.MultiChoiceModeListener但是这不适用于一个ListFragment类或标准的活动,这样我将如何去实现这个类.

我想要实现的基本功能是当有人长时间在FragmentA中的ListView中按下项目时,它会扩展ListFragment,操作栏会在上下文中更改,然后用户可以从ListView中选择多个项目.

感谢您的任何帮助,您可以提供.

android android-listfragment

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

使用KSoap2从Soap接收和处理Dictionary <string,List <string >>

我正在研究一个调用soap函数并返回一个的android应用程序Diction<string, List<string>>.

响应如下所示:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <retrieveDatabasesResponse xmlns="http://tempuri.org/">
         <retrieveDatabasesResult xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <a:KeyValueOfstringArrayOfstringty7Ep6D1>
               <a:Key>information_schema</a:Key>
               <a:Value>
                  <a:string>CHARACTER_SETS</a:string>
                  <a:string>COLLATIONS</a:string>
                  <a:string>COLLATION_CHARACTER_SET_APPLICABILITY</a:string>
                  <a:string>COLUMNS</a:string>
                  <a:string>COLUMN_PRIVILEGES</a:string>
                  <a:string>ENGINES</a:string>
                  <a:string>EVENTS</a:string>
                  <a:string>FILES</a:string>
                  <a:string>GLOBAL_STATUS</a:string>
                  <a:string>GLOBAL_VARIABLES</a:string>
                  <a:string>KEY_COLUMN_USAGE</a:string>
                  <a:string>PARAMETERS</a:string>
                  <a:string>PARTITIONS</a:string>
                  <a:string>PLUGINS</a:string>
                  <a:string>PROCESSLIST</a:string>
                  <a:string>PROFILING</a:string>
                  <a:string>REFERENTIAL_CONSTRAINTS</a:string>
                  <a:string>ROUTINES</a:string>
                  <a:string>SCHEMATA</a:string>
                  <a:string>SCHEMA_PRIVILEGES</a:string>
                  <a:string>SESSION_STATUS</a:string>
                  <a:string>SESSION_VARIABLES</a:string>
                  <a:string>STATISTICS</a:string>
                  <a:string>TABLES</a:string>
                  <a:string>TABLESPACES</a:string>
                  <a:string>TABLE_CONSTRAINTS</a:string>
                  <a:string>TABLE_PRIVILEGES</a:string>
                  <a:string>TRIGGERS</a:string>
                  <a:string>USER_PRIVILEGES</a:string>
                  <a:string>VIEWS</a:string>
                  <a:string>INNODB_BUFFER_PAGE</a:string>
                  <a:string>INNODB_TRX</a:string>
                  <a:string>INNODB_BUFFER_POOL_STATS</a:string>
                  <a:string>INNODB_LOCK_WAITS</a:string>
                  <a:string>INNODB_CMPMEM</a:string>
                  <a:string>INNODB_CMP</a:string>
                  <a:string>INNODB_LOCKS</a:string>
                  <a:string>INNODB_CMPMEM_RESET</a:string>
                  <a:string>INNODB_CMP_RESET</a:string>
                  <a:string>INNODB_BUFFER_PAGE_LRU</a:string>
               </a:Value>
            </a:KeyValueOfstringArrayOfstringty7Ep6D1>
            <a:KeyValueOfstringArrayOfstringty7Ep6D1>
               <a:Key>boardies_password_manager</a:Key>
               <a:Value>
                  <a:string>alarms</a:string>
                  <a:string>categories</a:string>
                  <a:string>passwords</a:string>
                  <a:string>settings</a:string>
                  <a:string>users</a:string>
               </a:Value>
            </a:KeyValueOfstringArrayOfstringty7Ep6D1>
            <a:KeyValueOfstringArrayOfstringty7Ep6D1>
               <a:Key>bugs</a:Key>
               <a:Value>
                  <a:string>alarms</a:string>
                  <a:string>comments</a:string>
                  <a:string>logfile_history</a:string>
                  <a:string>platforms</a:string>
                  <a:string>privileges</a:string>
                  <a:string>reports</a:string>
                  <a:string>requested_features</a:string>
                  <a:string>settings</a:string>
                  <a:string>short_bulletins</a:string> …
Run Code Online (Sandbox Code Playgroud)

android soap ksoap2

12
推荐指数
1
解决办法
462
查看次数

在C#中自动关闭消息框

我目前正在C#中开发一个应用程序,我在其中显示一个MessageBox.如何在几秒钟后自动关闭消息框?

c# wpf messagebox

11
推荐指数
1
解决办法
3万
查看次数

提供的依赖项只能是jar

我在Android Studio中有一个Android项目,以前我用过它以前都在工作,但是,我已经升级了Android Studio,现在我遇到了一个奇怪的问题.

在Android Studio的错误输出中,我有以下内容:

Warning: Project MyApp: provided dependencies can only be jars. com.google.android.gms:play-services.6.5.87 is an Android Library
Warning: Project MyApp: provided dependencies can only be jars. com.MyCompany.MyLibrary:aar:1.0 is an Android Library.
Run Code Online (Sandbox Code Playgroud)

下面是我的build.gradle文件.

apply plugin: 'android'



android {
    compileSdkVersion 21
    buildToolsVersion "20.0.0"

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

    defaultConfig {
        //applicationId "com.MyCompany.MyApp"
        minSdkVersion 14
        targetSdkVersion 21
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            debuggable false
        }
    }

    repositories {
        mavenLocal()
    }
}

dependencies {
    compile …
Run Code Online (Sandbox Code Playgroud)

android build.gradle android-gradle-plugin

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

视图传呼机隐藏在标签栏后面的片段

我的android项目中有Tab栏和ViewPager的问题.该应用程序具有一个活动,它包含一个标签布局,然后有一个代表每个标签的片段.

当活动打开时,它会发布到API以获取一些数据,并将数据放入数据适配器中,以便在每个片段中进行Recycler View和Card布局.

回收者视图将包含3个项目,但只显示2个项目,因为第一个项目隐藏在工具栏和/或标签栏下,如下面的屏幕截图所示.

下面是我的活动的布局文件

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="com.BoardiesITSolution.CritiMonApp.AppsActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
        <include layout="@layout/toolbar" />
        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabMode="fixed"
            app:tabGravity="fill" />
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
        <!--app:layout_behaviour="@string/appbar_scrolling_view_behaviour" />-->
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

下面是片段的布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <view
        android:id="@+id/recycler_view"
        class="android.support.v7.widget.RecyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerInParent="true" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

下面是卡片布局的布局

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:cardview="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="80dp"
    android:layout_margin="8dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:elevation="5dp">
        <TextView
            android:id="@+id/txtApplicationName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:maxLines="3"
            android:padding="8dp"
            android:textColor="#222"
            android:textSize="15dp"
            android:layout_centerInParent="true"/>

    </RelativeLayout>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)

下面是上面提到的屏幕截图,显示了问题.我已经像素化了一些文字,但它应该是我的意思,应该有3个项目,但第一项隐藏在标签栏下面.

显示问题的屏幕截图

感谢您的任何帮助,您可以提供

tabs android android-layout android-fragments android-recyclerview

11
推荐指数
2
解决办法
8225
查看次数

执行UPNP扫描不会返回飞利浦Hue Bridge

我正在尝试实现我自己的UpNP扫描,它主要是工作,并且为了证明这不是我,我有一个Windows程序,允许您发送数据包,看看有什么响应回来.

我正在向239.255.255.250端口发送数据包1900,我发送以下数据:

M-SEARCH * HTTP/1.1
Host: 239.255.255.250:1900
Man: "ssdp:discover"
MX: 10
ST: ssdp:all
Run Code Online (Sandbox Code Playgroud)

只是为了进一步的信息,在我的Java代码(Android)中,我有以下内容,但我得到与数据包测试器应用程序相同的响应:

try
        {
            byte[] sendData = new byte[1024];
            //byte[] receiveData = new byte[1024];
            byte[] receiveData;
            String mSearch = "M-SEARCH * HTTP/1.1\r\nHost: 239.255.255.250:1900\r\nMan: \"ssdp:discover\"\r\nMX: 10\r\nST: ssdp:all\r\n\r\n";
            sendData = mSearch.getBytes();

            DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, InetAddress.getByName("239.255.255.250"), 1900);

            DatagramSocket clientSocket = new DatagramSocket();
            clientSocket.send(sendPacket);

            while (keepGoing)
            {
                receiveData = new byte[1024];
                receivePacket = new DatagramPacket(receiveData, receiveData.length);
                clientSocket.receive(receivePacket);

                String response = new String(receivePacket.getData());

                if (response == …
Run Code Online (Sandbox Code Playgroud)

java android upnp philips-hue

11
推荐指数
1
解决办法
1365
查看次数

Android应用程序和模式锁定屏幕

我目前正在开发Android 2.2或更高版本的应用程序.

我想允许用户在访问应用程序之前启用登录.我想允许用户在各种类型的登录之间进行选择,如密码,密码或模式.

我想知道是否可以在我自己的应用程序中添加模式锁定.是否有一个插件我可以用来创建一个或使用Android的模式锁为我自己的应用程序.我只希望这个应用程序我不希望它改变实际设备的锁定方式.

感谢您的任何帮助,您可以提供.

android

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

从JavaScript中读取PHP cookie

我有一个PHP脚本,它设置一个名为user的cookie.我需要能够在javascript中读取此cookie中的值.

甚至可以做到这一点.

感谢您的任何帮助,您可以提供.

javascript php cookies

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