IMSIで表示/読み取りを取得したい(Dev Alpha Bでテスト済み)。問題は、モバイルネットワークコード、モバイル国コード、シリアル番号、IMSI(subscriberIdentifier)など、SimCardInfoの他のプロパティを読み取ることができることです。これがコードです
main.cpp
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
#include <bb/device/HardwareInfo>
#include <bb/device/SimCardInfo>
#include <QLocale>
#include <QTranslator>
#include <Qt/qdeclarativedebug.h>
using namespace bb::cascades;
using namespace bb::device;
Q_DECL_EXPORT int main(int argc, char **argv)
{
qmlRegisterUncreatableType<bb::device::HardwareInfo>("bb.device", 1, 0, "HardwareInfo", "");
qmlRegisterUncreatableType<bb::device::SimCardInfo>("bb.device", 1, 0, "SimCardInfo", "");
// this is where the server is started etc
Application app(argc, argv);
// localization support
QTranslator translator;
QString locale_string = QLocale().name();
QString filename = QString( "hwinfo_%1" ).arg( locale_string );
if (translator.load(filename, "app/native/qm")) {
app.installTranslator( &translator );
}
//create object
HardwareInfo hwInfo;
SimCardInfo simcardInfo;
QmlDocument *qml = QmlDocument::create("asset:///main.qml");
qml->setContextProperty("_hardware", &hwInfo);
qml->setContextProperty("_simcardinfo", &simcardInfo);
// create root object for the UI
AbstractPane *root = qml->createRootObject<AbstractPane>();
// set created root object as a scene
Application::instance()->setScene(root);
// we complete the transaction started in the app constructor and start the client event loop here
return Application::exec();
// when loop is exited the Application deletes the scene which deletes all its children (per qt rules for children)
}
main.qmlファイル
import bb.cascades 1.0
import bb.device 1.0
Page
{
Container
{
leftPadding: 20
topPadding: 20
Container
{
topMargin: 10
layout: StackLayout
{
orientation: LayoutOrientation.LeftToRight
}
Button
{
text: "retrieve"
onClicked:
{
lbl0.text = "Model name: " + _hardware.modelName
lbl1.text = "IMEI: " + _hardware.imei
lbl2.text = "IMSI: " + _simcardinfo.subscriberIdentifier
lbl3.text = "SN: " + _simcardinfo.serialNumber
lbl4.text = "Mobile Network Code: " + _simcardinfo.mobileNetworkCode
lbl5.text = "Mobile Country Code: " + _simcardinfo.mobileCountryCode
}
}
}
Container
{
layout: StackLayout {
}
Label
{
id:lbl0
}
Label
{
id:lbl1
}
Label
{
id:lbl2
}
Label
{
id:lbl3
}
Label
{
id:lbl4
}
Label
{
id:lbl5
}
}
}
}
どんな助けでも大歓迎です。
参照 http://developer.blackberry.com/cascades/reference/bb_device_simcardinfo.html _ _