本文整理汇总了Java中android.content.pm.PackageInstaller.Session方法的典型用法代码示例。如果您正苦于以下问题:Java PackageInstaller.Session方法的具体用法?Java PackageInstaller.Session怎么用?Java PackageInstaller.Session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.pm.PackageInstaller
的用法示例。
在下文中一共展示了PackageInstaller.Session方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installPackage
import android.content.pm.PackageInstaller; //导入方法依赖的package包/类
public static boolean installPackage(Context context, InputStream in, String packageName)
throws IOException {
PackageInstaller packageInstaller = context.getPackageManager().getPackageInstaller();
PackageInstaller.SessionParams params = new PackageInstaller.SessionParams(
PackageInstaller.SessionParams.MODE_FULL_INSTALL);
params.setAppPackageName(packageName);
// set params
int sessionId = packageInstaller.createSession(params);
PackageInstaller.Session session = packageInstaller.openSession(sessionId);
OutputStream out = session.openWrite("COSU", 0, -1);
byte[] buffer = new byte[65536];
int c;
while ((c = in.read(buffer)) != -1) {
out.write(buffer, 0, c);
}
session.fsync(out);
in.close();
out.close();
session.commit(createIntentSender(context, sessionId));
return true;
}
示例2: getStream
import android.content.pm.PackageInstaller; //导入方法依赖的package包/类
public final OutputStream getStream(String paramString1, String paramString2, long paramLong)
throws IOException
{
PackageInstaller.Session localSession = getSession(paramString1);
if (localSession == null)
{
FinskyLog.e("Can't open session for %s", new Object[] { paramString1 });
throw new IOException();
}
return new SessionStreamWrapper(localSession.openWrite(paramString2, 0L, paramLong), localSession);
}
示例3: SessionStreamWrapper
import android.content.pm.PackageInstaller; //导入方法依赖的package包/类
public SessionStreamWrapper(OutputStream paramOutputStream, PackageInstaller.Session paramSession)
{
super();
this.stream = paramOutputStream;
this.session = paramSession;
}