two programs realize installing *.apk and pushing files

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * =====================================================================================
 *
 *       Filename:  install.c
 *    Description:  Install *.apk file to your android phone by draging an apk file to the program
 *        Version:  1.0
 *        Created:  2014/3/4 10:35:12
 *       Revision:  none
 *       Compiler:  gcc
 *         Author:  Sumit.lc, sulinke1133@gmail.com
 *
 * =====================================================================================
 */

#include <stdio.h>
int main ( int argc, char *argv[] )
{
    char total[256]={0};                         
    sprintf(total, "%s%s", "adb install ", argv[1]);         /* add commands together  */
    printf ( "Waiting for device online...n" );            /* make sure the device is connected */
    system("adb wait-for-device");
    system(total);                              /* run the command */
    return 0;
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * =====================================================================================
 *
 *       Filename:  push.c
 *    Description:  Push file to "/sdcard/" and the filename not be changed
 *        Version:  1.0
 *        Created:  2014/3/4 10:46:56
 *       Revision:  none
 *       Compiler:  gcc
 *         Author:  Sumit.lc (), sulinke1133@gmail.com
 *
 * =====================================================================================
 */

#include <stdio.h>
#include <libgen.h>
int main ( int argc, char *argv[] )
{
    char total[256]={0};
	sprintf(total, "%s%s %s%s", "adb push ",argv[1],"/sdcard/",basename(argv[1]) );
    printf ( "Waiting for device online...n" );
    system("adb wait-for-device");
    system(total);
    return 0;
}
Licensed under CC BY-NC-SA 4.0
记录平时瞎折腾遇到的各种问题, 方便查找
使用 Hugo 构建
主题 Stack 3.29.0Jimmy 设计