gio

作为Android开发,你必须要掌握的Android冷启动优化知识

。_饼干妹妹 提交于 2021-02-05 20:38:12
我们搞Android开发这一行,很多时候都在追求新技术,但是实际上,要想在Android领域有长远的发展,还有很多东西要去了解,虽然不是最前沿的,但却是最基础的最需要的。 今天要和大家分享的就是作为Android开发必须掌握的Android冷启动优化。 原文地址: https://www.jianshu.com/p/0d2a093a6d48 前言 事件发生在发包上线的前两天,在某某云进行移动测试时,提示冷启动速度低于平均值的问题,之前自己也曾尝试过优化,但是发现效果并不是很明显,作为一个有追求的开发者,趁着有点空闲时间,要好好研究一下冷启动优化问题。 App的启动流程 我们可以了解一下官方文档 《App startup time》 对App启动的描述。应用启动分为冷启动、热启动、温启动。而冷启动是应用程序从零开始,里面涉及到更复杂的知识。我们这次主要是对应用的冷启动进行分析和优化。 应用在冷启动的时候,需要执行下面三个任务: 加载和启动应用程序; App启动之后立即展示出一个空白的启动窗口; 创建App程序的进程; 在这三个任务执行后,系统创建了应用进程,那么应用进程会执行下一步: 创建App对象; 启动Main Thread; 创建启动页的Activity; 加载View; 布置屏幕; 进行初始绘制; 当应用进程完成初始绘制之后

How do I initialize a GActionMap variable?

﹥>﹥吖頭↗ 提交于 2021-02-05 07:35:22
问题 I want to know how to initialize a GActionMap variable. I search here https://developer.gnome.org/gio/stable/GActionMap.html to find a function that instances a GActionMap, but I didn't find it there and anywhere. I was trying to insert some actions in my application, to use the function item = g_menu_item_new(labelItem, "sair"); where item is a menu item, labelItem is a menu item label and sair is the function name that I want to trigger when the item is clicked. But when I run the code, I

Getting error while reading unicode file in C

笑着哭i 提交于 2020-01-06 12:45:25
问题 I want to read a unicode file in C (Cygwin/GCC) using the following code: #include <stdio.h> #include <stdlib.h> #include <glib.h> void split_parse(char* text){ char** res = g_strsplit(text, "=", 2); printf("Key = %s : ", res[0]); printf("Value = %s", res[1]); printf("\n"); } int main(int argc, char **argv) { setenv ("CYGWIN", "nodosfilewarning", 1); GIOChannel *channel; GError *err = NULL; int reading = 0; const gchar* enc; guchar magic[2] = { 0 }; gsize bytes_read = 0; const char* filename

Gio.MemoryInputStream does not free memory when closed

故事扮演 提交于 2019-12-24 01:25:12
问题 Running Python 3.4 on Windows 7, the close function of Gio.MemoryInputStream does not free the memory, as it should. The test code is : from gi.repository import Gio import os, psutil process = psutil.Process(os.getpid()) for i in range (1,10) : input_stream = Gio.MemoryInputStream.new_from_data(b"x" * 10**7) x = input_stream.close_async(2) y = int(process.memory_info().rss / 10**6) # Get the size of memory used by the program print (x, y) This returns : True 25 True 35 True 45 True 55 True

Can't change dconf-entry with GSettings

元气小坏坏 提交于 2019-12-23 13:27:18
问题 I'm currently building a simple application on Gjs, which should change the background-image of my gnome-shell. A solution on how this can be done using the gsettings -tool can be found here. Since I want to build a desktop-application around it, I want to change the org.gnome.desktop.background.picture-uri -key by using Gio's GSettings-class. But using the set_X() -method does not change the value of the key. This is my code to change the gsettings value: var gio = imports.gi.Gio; // Get the

Async HTTP request using GIO

牧云@^-^@ 提交于 2019-12-14 02:18:18
问题 I would appreciate an example on how to perform an async HTTP POST request using Python's GIO binding. Edit : Example sought without using Twisted. 回答1: An example using Twisted Deferred objects is available on James Henstridge's blog. 回答2: Sorry this is not HTTP POST (just GET), but it is using Gio to asynchronously request a URL, with a callback that processes the resulting data when it's done downloading. https://github.com/robru/gottengeography/blob

installing PyGObject via pip in virtualenv [duplicate]

浪子不回头ぞ 提交于 2019-12-12 08:24:11
问题 This question already has answers here : Python cannot install PyGObject (3 answers) Closed 2 years ago . I'm actually upgrading an old django app from python2.7 to python3.4. While installing pygobject via pip, I got this error: Collecting pygobject Using cached pygobject-2.28.3.tar.bz2 Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 20, in <module> File "/tmp/pip-build-9dp0wn96/pygobject/setup.py", line 272 raise SystemExit,

How to use Gnome GIO to read a file by chunks in non-blocking way?

江枫思渺然 提交于 2019-12-12 01:42:41
问题 What is the right (GIO/Glib/GTK/Gnome) way to process GInputStream in non-blocking manner and chunk-by-chunk? I have an application which is downloading (through libsoup) and processing a data stream in chunks and doing other actions in parallel. I am calling g_input_stream_read_async on GInputStream (received from soup_session_send_finish and giving it a reasonable size of chunk to read (in my case 2048 bytes). After I receive a g_input_stream_read_async callback, I want to continue reading

glib network connection example

做~自己de王妃 提交于 2019-12-10 08:57:21
问题 Can you advice some network connection example made with glib/gio libraries. There is quite a good reference manual, but no full example even for basic things. It will be used for simple sending and receiving files as a part of program. 回答1: How about like this? There is similar question at Fetch a file from web: in GTK using C #include <gio/gio.h> int main() { const gchar *uri = "https://stackoverflow.com/questions/5758770/"; GFile *in; GFile *out; GError *error = NULL; gboolean ret; g_type

How do I register a profile with bluez using dbus/gio?

为君一笑 提交于 2019-12-08 11:25:57
问题 I'm trying to register a profile with bluez through D-Bus/Gio. When I call RegisterProfile everything goes OK. I check my GError and it's NULL and my return value is an empty GVariant. I've tried many things, but here is my latest code. When I run it, it prints "g_dbus_connection_call_sync succeeded", but I can't see my new profile in D-Bus using d-feet and I cannot connect to it using a my test device. I know the code on the test device works, or at least did work with straight bluez, but I