import
java.io.FileOutputStream
;
import
com.gc.android.market.api.MarketSession
;
import
com.gc.android.market.api.MarketSession.Callback
;
import
com.gc.android.market.api.model.Market.AppsRequest
;
import
com.gc.android.market.api.model.Market.CommentsRequest
;
import
com.gc.android.market.api.model.Market.GetImageRequest
;
import
com.gc.android.market.api.model.Market.GetImageResponse
;
import
com.gc.android.market.api.model.Market.ResponseContext
;
import
com.gc.android.market.api.model.Market.GetImageRequest.AppImageUsage
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
try
{
if
(
args
.
length
2
?
args
[
2
]
:
"Test"
;
MarketSession
session
=
new
MarketSession
();
session
.
getContext
().
setAndroidId
(
"0123012301230123"
);
session
.
getContext
().
setDeviceAndSdkVersion
(
"passion:8"
);
session
.
getContext
().
setVersion
(
1002012
);
System
.
out
.
println
(
"Login..."
);
session
.
login
(
login
,
password
);
System
.
out
.
println
(
"Login done"
);
AppsRequest
appsRequest
=
AppsRequest
.
newBuilder
()
.
setQuery
(
query
)
.
setStartIndex
(
2
).
setEntriesCount
(
10
)
.
setWithExtendedInfo
(
true
)
.
build
();
CommentsRequest
commentsRequest
=
CommentsRequest
.
newBuilder
()
.
setAppId
(
"7065399193137006744"
)
.
setStartIndex
(
0
)
.
setEntriesCount
(
10
)
.
build
();
GetImageRequest
imgReq
=
GetImageRequest
.
newBuilder
().
setAppId
(
"-7934792861962808905"
)
.
setImageUsage
(
AppImageUsage
.
SCREENSHOT
)
.
setImageId
(
"1"
)
.
build
();
MarketSession
.
Callback
callback
=
new
MarketSession
.
Callback
()
{
@Override
public
void
onResult
(
ResponseContext
context
,
Object
response
)
{
System
.
out
.
println
(
"Response : "
+
response
);
}
};
session
.
append
(
appsRequest
,
callback
);
session
.
flush
();
session
.
append
(
imgReq
,
new
Callback
()
{
@Override
public
void
onResult
(
ResponseContext
context
,
GetImageResponse
response
)
{
try
{
FileOutputStream
fos
=
new
FileOutputStream
(
"icon.png"
);
fos
.
write
(
response
.
getImageData
().
toByteArray
());
fos
.
close
();
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
}
});
session
.
flush
();
session
.
append
(
commentsRequest
,
callback
);
session
.
flush
();
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
}
}
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.e1idc.net