PHP Custom APK installation package instance, PHPAPK installation package
This article describes the PHP custom APK installation package method, share to everyone for your reference. The implementation method is as follows:
As we all know, apk format installation file is the installation file of Android Intelligent system, let's take a look at a custom APK installation package instance with PHP implementation.
First, demand:
You need to implement an activity that recommends a friend installation for a product, and each member downloads his or her own installation package (which records information about the member).
Second, the idea:
After understanding, found that the APK installation package was originally just a zip vest, using the PHP ziparchive class can manipulate the file.
Third, the implementation of code:
Copy the Code Code as follows://source file
$apk = "gb.apk";
Generate Temporary files
$file = Tempnam ("tmp", "zip");
Copying files
if (False===file_put_contents ($file, file_get_contents ($apk))) {
Exit (' Copy faild! ');
}
Open temporary file
$zip = new Ziparchive ();
$zip->open ($file);
Add File
Because the APK limit can only modify the files in this directory, otherwise it will be reported invalid APK package
$zip->addfromstring (' Meta-inf/extends.json ', Json_encode (Array (' author ' = ' Deeka ')));
Close zip
$zip->close ();
Download file
Header ("Content-type:application/zip");
Header ("Content-length:".) FileSize ($file));
Header ("content-disposition:attachment; Filename=\ "{$apk}\" ");
Output binary Stream
ReadFile ($file);
Delete temporary files
Unlink ($file);
I hope this article is helpful to everyone's PHP programming.
Can the PHP page specify whether to send a message to an Android APK program that accesses it?
You are now the only way to do this, only let the APK timer refresh, unless the APK and the server keep the connection constantly open, or the server PHP is the service to find the APK, because your apk is not a server, can not be executed in turn.
If you want to relieve server pressure, you must make your apk into a server, listen to a network port, and allow other devices on the network to connect. However, this project will be very large, the logic of the APK and PHP will become very complex, because PHP to find the apk when needed, if the phone is delayed to turn off the computer, and the APK in order to wait for PHP to connect at any time, to work as a service, stand by.
Download mobile app, apk format is downloaded to php what to do?
PHP file is a Dynamic Web page, the download of PHP files are recorded in the APK file address. You can only click it to open the page and then download it. Later download, click the right button to see the property, if the address bar at the end of the APK, you can use your method, not the words need to open this link, continue to find ...
http://www.bkjia.com/PHPjc/897012.html www.bkjia.com true http://www.bkjia.com/PHPjc/897012.html techarticle PHP Custom APK installation package instance, phpapk installation package This article describes the PHP custom APK installation package method, share to everyone for your reference. The concrete implementation method is as follows: Well-known, ...